1 #ifndef SQUID_FORWARD_H
2 #define SQUID_FORWARD_H
6 #include "comm/Connection.h"
8 #include "ip/Address.h"
14 typedef RefCount
<AccessLogEntry
> AccessLogEntryPointer
;
19 * Returns the TOS value that we should be setting on the connection
20 * to the server, based on the ACL.
22 tos_t
GetTosToServer(HttpRequest
* request
);
25 * Returns the Netfilter mark value that we should be setting on the
26 * connection to the server, based on the ACL.
28 nfmark_t
GetNfmarkToServer(HttpRequest
* request
);
30 class FwdState
: public RefCountable
33 typedef RefCount
<FwdState
> Pointer
;
35 static void initModule();
37 /// Initiates request forwarding to a peer or origin server.
38 static void Start(const Comm::ConnectionPointer
&client
, StoreEntry
*, HttpRequest
*, const AccessLogEntryPointer
&alp
);
39 /// Same as Start() but no master xaction info (AccessLogEntry) available.
40 static void fwdStart(const Comm::ConnectionPointer
&client
, StoreEntry
*, HttpRequest
*);
42 /// This is the real beginning of server connection. Call it whenever
43 /// the forwarding server destination has changed and a new one needs to be opened.
44 /// Produces the cannot-forward error on fail if no better error exists.
45 void startConnectionOrFail();
47 void fail(ErrorState
*err
);
48 void unregister(Comm::ConnectionPointer
&conn
);
49 void unregister(int fd
);
51 void handleUnregisteredServerEnd();
53 bool reforwardableStatus(http_status s
);
54 void serverClosed(int fd
);
56 void connectDone(const Comm::ConnectionPointer
& conn
, comm_err_t status
, int xerrno
);
57 void connectTimeout(int fd
);
59 void negotiateSSL(int fd
);
61 bool checkRetriable();
63 void pconnPush(Comm::ConnectionPointer
& conn
, const char *domain
);
65 bool dontRetry() { return flags
.dont_retry
; }
67 void dontRetry(bool val
) { flags
.dont_retry
= val
; }
69 /** return a ConnectionPointer to the current server connection (may or may not be open) */
70 Comm::ConnectionPointer
const & serverConnection() const { return serverConn
; };
73 // hidden for safer management of self; use static fwdStart
74 FwdState(const Comm::ConnectionPointer
&client
, StoreEntry
*, HttpRequest
*, const AccessLogEntryPointer
&alp
);
75 void start(Pointer aSelf
);
77 #if STRICT_ORIGINAL_DST
78 void selectPeerForIntercepted();
80 static void logReplyStatus(int tries
, http_status status
);
81 void doneWithRetries();
84 ErrorState
*makeConnectingError(const err_type type
) const;
85 static void RegisterWithCacheManager(void);
90 AccessLogEntryPointer al
; ///< info for the future access.log entry
92 static void abort(void*);
97 Comm::ConnectionPointer clientConn
; ///< a possibly open connection to the client.
102 // AsyncCalls which we set and may need cancelling.
104 AsyncCall::Pointer connector
; ///< a call linking us to the ConnOpener producing serverConn.
108 unsigned int connected_okay
:1; ///< TCP link ever opened properly. This affects retry of POST,PUT,CONNECT,etc
109 unsigned int dont_retry
:1;
110 unsigned int forward_completed
:1;
113 /** connections to open, in order, until successful */
114 Comm::ConnectionList serverDestinations
;
116 Comm::ConnectionPointer serverConn
; ///< a successfully opened connection to a server.
118 /// possible pconn race states
119 typedef enum { raceImpossible
, racePossible
, raceHappened
} PconnRace
;
120 PconnRace pconnRace
; ///< current pconn race state
122 // NP: keep this last. It plays with private/public
123 CBDATA_CLASS2(FwdState
);
126 #endif /* SQUID_FORWARD_H */