]> git.ipfire.org Git - thirdparty/squid.git/blame - src/adaptation/AccessCheck.h
Boilerplate: update copyright blurbs on src/
[thirdparty/squid.git] / src / adaptation / AccessCheck.h
CommitLineData
bbc27441
AJ
1/*
2 * Copyright (C) 1996-2014 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
b6b637eb
AR
9#ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
10#define SQUID_ADAPTATION__ACCESS_CHECK_H
62c7f90e 11
af0ded40 12#include "AccessLogEntry.h"
86c63190 13#include "acl/Acl.h"
62c7f90e
AR
14#include "adaptation/Elements.h"
15#include "adaptation/forward.h"
79628299 16#include "adaptation/Initiator.h"
a22e6cd3 17#include "adaptation/ServiceFilter.h"
602d9612 18#include "base/AsyncJob.h"
62c7f90e
AR
19
20class HttpRequest;
21class HttpReply;
127dce76 22class ACLFilledChecklist;
62c7f90e 23
26ac0430
AJ
24namespace Adaptation
25{
62c7f90e
AR
26
27class AccessRule;
28
29// checks adaptation_access rules to find a matching adaptation service
30class AccessCheck: public virtual AsyncJob
31{
62c7f90e 32public:
a22e6cd3 33 typedef void AccessCheckCallback(ServiceGroupPointer group, void *data);
abd4b611
AR
34
35 // use this to start async ACL checks; returns true if started
26ac0430 36 static bool Start(Method method, VectPoint vp, HttpRequest *req,
af0ded40 37 HttpReply *rep, AccessLogEntry::Pointer &al, Adaptation::Initiator *initiator);
abd4b611
AR
38
39protected:
40 // use Start to start adaptation checks
79628299 41 AccessCheck(const ServiceFilter &aFilter, Adaptation::Initiator *);
62c7f90e
AR
42 ~AccessCheck();
43
44private:
a22e6cd3 45 const ServiceFilter filter;
79628299 46 CbcPointer<Adaptation::Initiator> theInitiator; ///< the job which ordered this access check
127dce76 47 ACLFilledChecklist *acl_checklist;
62c7f90e
AR
48
49 typedef int Candidate;
c8ea3cc0 50 typedef std::vector<Candidate> Candidates;
62c7f90e 51 Candidates candidates;
a22e6cd3
AR
52 Candidate topCandidate() const { return *candidates.begin(); }
53 ServiceGroupPointer topGroup() const; // may return nil
62c7f90e 54
a22e6cd3
AR
55 void callBack(const ServiceGroupPointer &g);
56 bool isCandidate(AccessRule &r);
62c7f90e
AR
57
58public:
62c7f90e 59 void checkCandidates();
2efeb0b7
AJ
60 static void AccessCheckCallbackWrapper(allow_t, void*);
61 void noteAnswer(allow_t answer);
62c7f90e 62
dd5d7172 63protected:
a22e6cd3 64 // AsyncJob API
dd5d7172 65 virtual void start();
a22e6cd3 66 virtual bool doneAll() const { return false; } /// not done until mustStop
62c7f90e 67
53340485 68 bool usedDynamicRules();
dd5d7172
AR
69 void check();
70
62c7f90e
AR
71private:
72 CBDATA_CLASS2(AccessCheck);
73};
74
75} // namespace Adaptation
76
b6b637eb 77#endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */