Connection.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
151 
153  int flags;
154 
156 
157 #if USE_SQUID_EUI
160 #endif
161 
162 private:
165 
167  time_t startTime_;
168 
171 };
172 
173 }; // namespace Comm
174 
175 std::ostream &operator << (std::ostream &os, const Comm::Connection &conn);
176 
177 inline std::ostream &
178 operator << (std::ostream &os, const Comm::ConnectionPointer &conn)
179 {
180  if (conn != NULL)
181  os << *conn;
182  return os;
183 }
184 
185 #endif
186 
time_t timeLeft(const time_t idleTimeout) const
Definition: Connection.cc:119
Security::NegotiationHistory * tlsNegotiations()
Definition: Connection.cc:129
nfmark_t nfmark
Definition: Connection.h:150
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:159
time_t squid_curtime
Definition: stub_time.cc:17
Eui::Eui48 remoteEui48
Definition: Connection.h:158
unsigned char tos_t
Definition: forward.h:26
const Security::NegotiationHistory * hasTlsNegotiations() const
Definition: Connection.h:124
Security::NegotiationHistory * tlsHistory
Definition: Connection.h:170
#define USER_IDENT_SZ
Definition: defines.h:60
time_t connectTimeout(const time_t fwdStart) const
Definition: Connection.cc:137
std::ostream & operator<<(std::ostream &os, const Comm::Connection &conn)
Definition: Connection.cc:157
CachePeer * getPeer() const
Definition: Connection.cc:97
Ip::Address local
Definition: Connection.h:135
char rfc931[USER_IDENT_SZ]
Definition: Connection.h:155
void setPeer(CachePeer *p)
Definition: Connection.cc:106
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:87
ConnectionPointer copyDetails() const
Definition: Connection.cc:57
time_t startTime() const
Definition: Connection.h:106
CachePeer * peer_
Definition: Connection.h:164
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