Squid Web Cache master
Loading...
Searching...
No Matches
Tree.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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#include "squid.h"
10#include "acl/Checklist.h"
11#include "acl/Tree.h"
12#include "wordlist.h"
13
16{
17 return actionAt(lastMatch_ - nodes.begin());
18}
19
22{
23 if (actions.empty())
24 return ACCESS_DUNNO;
25 return actions.back();
26}
27
30Acl::Tree::actionAt(const Nodes::size_type pos) const
31{
32 assert(pos < nodes.size());
33 if (actions.size()) {
34 assert(actions.size() == nodes.size());
35 return actions[pos];
36 }
37 // default for matched rules in trees without actions
38 return ACCESS_ALLOWED;
39}
40
41void
43{
44 // either all rules have actions or none
45 assert(nodes.size() == actions.size());
46 InnerNode::add(rule);
47 actions.push_back(action);
48}
49
50void
52{
53 // either all rules have actions or none
54 assert(actions.empty());
55 InnerNode::add(rule);
56}
57
58bool
59Acl::Tree::bannedAction(ACLChecklist *checklist, Nodes::const_iterator node) const
60{
61 if (actions.size()) {
62 assert(actions.size() == nodes.size());
63 const Nodes::size_type pos = node - nodes.begin();
64 return checklist->bannedAction(actions.at(pos));
65 }
66 return false;
67}
68
#define assert(EX)
Definition assert.h:17
bool bannedAction(const Acl::Answer &action) const
whether the action is banned or not
Definition Checklist.cc:350
void add(Acl::Node *node)
appends the node to the collection and takes control over it
Definition InnerNode.cc:36
Nodes nodes
children of this intermediate node
Definition InnerNode.h:51
Nodes::const_iterator lastMatch_
Definition BoolOps.h:72
bool bannedAction(ACLChecklist *, Nodes::const_iterator) const override
Acl::OrNode API.
Definition Tree.cc:59
Answer actionAt(const Nodes::size_type pos) const
computes action that corresponds to the position of the matched rule
Definition Tree.cc:30
void add(Acl::Node *rule, const Answer &action)
appends and takes control over the rule with a given action
Definition Tree.cc:42
Answer winningAction() const
Returns the corresponding action after a successful tree match.
Definition Tree.cc:15
Answer lastAction() const
what action to use if no nodes matched
Definition Tree.cc:21
@ ACCESS_ALLOWED
Definition Acl.h:42
@ ACCESS_DUNNO
Definition Acl.h:43
Definition parse.c:104