Connection.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 /* DEBUG: section 05 Socket Functions */
10 
11 #ifndef _SQUIDCONNECTIONDETAIL_H_
12 #define _SQUIDCONNECTIONDETAIL_H_
13 
14 #include "comm/forward.h"
15 #include "defines.h"
16 #if USE_SQUID_EUI
17 #include "eui/Eui48.h"
18 #include "eui/Eui64.h"
19 #endif
20 #include "hier_code.h"
21 #include "ip/Address.h"
22 #include "ip/forward.h"
23 #include "mem/forward.h"
24 #include "SquidTime.h"
25 
26 #include <iosfwd>
27 #include <ostream>
28 
29 class CachePeer;
30 
31 namespace Security
32 {
33 class NegotiationHistory;
34 };
35 
36 namespace Comm
37 {
38 
39 /* TODO: make these a struct of boolean flags members in the connection instead of a bitmap.
40  * we can't do that until all non-comm code uses Commm::Connection objects to create FD
41  * currently there is code still using comm_open() and comm_openex() synchronously!!
42  */
43 #define COMM_UNSET 0x00
44 #define COMM_NONBLOCKING 0x01 // default flag.
45 #define COMM_NOCLOEXEC 0x02
46 #define COMM_REUSEADDR 0x04 // shared FD may be both accept()ing and read()ing
47 #define COMM_DOBIND 0x08 // requires a bind()
48 #define COMM_TRANSPARENT 0x10 // arrived via TPROXY
49 #define COMM_INTERCEPTION 0x20 // arrived via NAT
50 
65 class Connection : public RefCountable
66 {
68 
69 public:
70  Connection();
71 
73  ~Connection();
74 
79 
81  void close();
82 
84  void noteClosure();
85 
87  bool isOpen() const { return (fd >= 0); }
88 
92  void setAddrs(const Ip::Address &aLocal, const Ip::Address &aRemote) {local = aLocal; remote = aRemote;}
93 
98  CachePeer * getPeer() const;
99 
103  void setPeer(CachePeer * p);
104 
106  time_t startTime() const {return startTime_;}
107 
109  time_t lifeTime() const {return squid_curtime - startTime_;}
110 
112  time_t timeLeft(const time_t idleTimeout) const;
113 
119  time_t connectTimeout(const time_t fwdStart) const;
120 
122 
125 
126 private:
128  Connection(const Connection &c);
129 
131  Connection & operator =(const Connection &c);
132 
133 public:
136 
139 
142 
144  int fd;
145 
148 
153 
161 
163  int flags;
164 
166 
167 #if USE_SQUID_EUI
170 #endif
171 
172 private:
175 
177  time_t startTime_;
178 
181 };
182 
183 }; // namespace Comm
184 
185 std::ostream &operator << (std::ostream &os, const Comm::Connection &conn);
186 
187 inline std::ostream &
188 operator << (std::ostream &os, const Comm::ConnectionPointer &conn)
189 {
190  if (conn != NULL)
191  os << *conn;
192  return os;
193 }
194 
195 #endif
196 
time_t timeLeft(const time_t idleTimeout) const
Definition: Connection.cc:120
Security::NegotiationHistory * tlsNegotiations()
Definition: Connection.cc:130
nfmark_t nfmark
Definition: Connection.h:152
time_t lifeTime() const
Definition: Connection.h:109
Connection & operator=(const Connection &c)
char * p
Definition: membanger.c:43
int conn
the current server connection FD
Definition: Transport.cc:26
Eui::Eui64 remoteEui64
Definition: Connection.h:169
time_t squid_curtime
Definition: stub_time.cc:17
nfmark_t nfConnmark
Definition: Connection.h:160
Eui::Eui48 remoteEui48
Definition: Connection.h:168
unsigned char tos_t
Definition: forward.h:26
const Security::NegotiationHistory * hasTlsNegotiations() const
Definition: Connection.h:124
Security::NegotiationHistory * tlsHistory
Definition: Connection.h:180
#define USER_IDENT_SZ
Definition: defines.h:60
time_t connectTimeout(const time_t fwdStart) const
Definition: Connection.cc:138
std::ostream & operator<<(std::ostream &os, const Comm::Connection &conn)
Definition: Connection.cc:158
CachePeer * getPeer() const
Definition: Connection.cc:98
Ip::Address local
Definition: Connection.h:135
char rfc931[USER_IDENT_SZ]
Definition: Connection.h:165
void setPeer(CachePeer *p)
Definition: Connection.cc:107
Ip::Address remote
Definition: Connection.h:138
hier_code
Definition: hier_code.h:12
bool isOpen() const
Definition: Connection.h:87
hier_code peerType
Definition: Connection.h:141
MEMPROXY_CLASS(Comm::Connection)
void noteClosure()
Definition: Connection.cc:88
ConnectionPointer copyDetails() const
Definition: Connection.cc:57
time_t startTime() const
Definition: Connection.h:106
CachePeer * peer_
Definition: Connection.h:174
void setAddrs(const Ip::Address &aLocal, const Ip::Address &aRemote)
Definition: Connection.h:92
uint32_t nfmark_t
Definition: forward.h:25
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors