]> git.ipfire.org Git - thirdparty/squid.git/blob - src/forward.h
Author: Andrew Beverley <andy@andybev.com>
[thirdparty/squid.git] / src / forward.h
1 #ifndef SQUID_FORWARD_H
2 #define SQUID_FORWARD_H
3
4 /* forward decls */
5
6 class ErrorState;
7 class HttpRequest;
8
9 #include "comm.h"
10 #include "hier_code.h"
11 #include "ip/Address.h"
12
13 /**
14 * Returns the TOS value that we should be setting on the connection
15 * to the server, based on the ACL.
16 */
17 tos_t GetTosToServer(HttpRequest * request);
18
19 /**
20 * Returns the Netfilter mark value that we should be setting on the
21 * connection to the server, based on the ACL.
22 */
23 nfmark_t GetNfmarkToServer(HttpRequest * request);
24
25
26 class FwdServer
27 {
28 public:
29 peer *_peer; /* NULL --> origin server */
30 hier_code code;
31 FwdServer *next;
32 };
33
34 class FwdState : public RefCountable
35 {
36 public:
37 typedef RefCount<FwdState> Pointer;
38 ~FwdState();
39 static void initModule();
40
41 static void fwdStart(int fd, StoreEntry *, HttpRequest *);
42 void startComplete(FwdServer *);
43 void startFail();
44 void fail(ErrorState *err);
45 void unregister(int fd);
46 void complete();
47 void handleUnregisteredServerEnd();
48 int reforward();
49 bool reforwardableStatus(http_status s);
50 void serverClosed(int fd);
51 void connectStart();
52 void connectDone(int server_fd, const DnsLookupDetails &dns, comm_err_t status, int xerrno);
53 void connectTimeout(int fd);
54 void initiateSSL();
55 void negotiateSSL(int fd);
56 bool checkRetry();
57 bool checkRetriable();
58 void dispatch();
59 void pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr);
60
61 bool dontRetry() { return flags.dont_retry; }
62
63 void dontRetry(bool val) { flags.dont_retry = val; }
64
65 bool ftpPasvFailed() { return flags.ftp_pasv_failed; }
66
67 void ftpPasvFailed(bool val) { flags.ftp_pasv_failed = val; }
68
69 static void serversFree(FwdServer **);
70
71 private:
72 // hidden for safer management of self; use static fwdStart
73 FwdState(int fd, StoreEntry *, HttpRequest *);
74 void start(Pointer aSelf);
75
76 static void logReplyStatus(int tries, http_status status);
77 void updateHierarchyInfo();
78 void doneWithRetries();
79 void completed();
80 void retryOrBail();
81 ErrorState *makeConnectingError(const err_type type) const;
82 static void RegisterWithCacheManager(void);
83
84 #if WIP_FWD_LOG
85
86 void uninit /**DOCS_NOSEMI*/
87 static void logRotate /**DOCS_NOSEMI*/
88 void status() /**DOCS_NOSEMI*/
89 #endif
90
91 public:
92 StoreEntry *entry;
93 HttpRequest *request;
94 int server_fd;
95 FwdServer *servers;
96 static void abort(void*);
97
98 private:
99 Pointer self;
100 ErrorState *err;
101 int client_fd;
102 time_t start_t;
103 int n_tries;
104 int origin_tries;
105 #if WIP_FWD_LOG
106
107 http_status last_status;
108 #endif
109
110 struct {
111 unsigned int dont_retry:1;
112 unsigned int ftp_pasv_failed:1;
113 unsigned int forward_completed:1;
114 } flags;
115
116 Ip::Address src; /* Client address for this connection. Needed for transparent operations. */
117
118 // NP: keep this last. It plays with private/public
119 CBDATA_CLASS2(FwdState);
120 };
121
122 #endif /* SQUID_FORWARD_H */