]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/AccessCheck.h
Prep for merge from trunk: undo branch r13313, r13312, and r13311 that were
[thirdparty/squid.git] / src / adaptation / AccessCheck.h
1 #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
2 #define SQUID_ADAPTATION__ACCESS_CHECK_H
3
4 #include "AccessLogEntry.h"
5 #include "acl/Acl.h"
6 #include "adaptation/Elements.h"
7 #include "adaptation/forward.h"
8 #include "adaptation/Initiator.h"
9 #include "adaptation/ServiceFilter.h"
10 #include "base/AsyncJob.h"
11
12 class HttpRequest;
13 class HttpReply;
14 class ACLFilledChecklist;
15
16 namespace Adaptation
17 {
18
19 class AccessRule;
20
21 // checks adaptation_access rules to find a matching adaptation service
22 class AccessCheck: public virtual AsyncJob
23 {
24 public:
25 typedef void AccessCheckCallback(ServiceGroupPointer group, void *data);
26
27 // use this to start async ACL checks; returns true if started
28 static bool Start(Method method, VectPoint vp, HttpRequest *req,
29 HttpReply *rep, AccessLogEntry::Pointer &al, Adaptation::Initiator *initiator);
30
31 protected:
32 // use Start to start adaptation checks
33 AccessCheck(const ServiceFilter &aFilter, Adaptation::Initiator *);
34 ~AccessCheck();
35
36 private:
37 const ServiceFilter filter;
38 CbcPointer<Adaptation::Initiator> theInitiator; ///< the job which ordered this access check
39 ACLFilledChecklist *acl_checklist;
40
41 typedef int Candidate;
42 typedef std::vector<Candidate> Candidates;
43 Candidates candidates;
44 Candidate topCandidate() const { return *candidates.begin(); }
45 ServiceGroupPointer topGroup() const; // may return nil
46
47 void callBack(const ServiceGroupPointer &g);
48 bool isCandidate(AccessRule &r);
49
50 public:
51 void checkCandidates();
52 static void AccessCheckCallbackWrapper(allow_t, void*);
53 void noteAnswer(allow_t answer);
54
55 protected:
56 // AsyncJob API
57 virtual void start();
58 virtual bool doneAll() const { return false; } /// not done until mustStop
59
60 bool usedDynamicRules();
61 void check();
62
63 private:
64 CBDATA_CLASS2(AccessCheck);
65 };
66
67 } // namespace Adaptation
68
69 #endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */