]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/ConnMark.cc
Reworked packet/connection marking (#170)
[thirdparty/squid.git] / src / acl / ConnMark.cc
CommitLineData
653d9927
A
1/*
2 * Copyright (C) 1996-2018 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/* DEBUG: section 28 Access Control */
10
11#include "squid.h"
12#include "acl/ConnMark.h"
13#include "acl/FilledChecklist.h"
14#include "client_side.h"
15#include "Debug.h"
16#include "http/Stream.h"
17#include "sbuf/Stream.h"
18
19bool
20Acl::ConnMark::empty() const
21{
22 return false;
23}
24
653d9927
A
25void
26Acl::ConnMark::parse()
27{
28 while (const char *t = ConfigParser::strtokFile()) {
29 SBuf token(t);
30 Parser::Tokenizer tokenizer(token);
244da4ad
AG
31 const auto mc = Ip::NfMarkConfig::Parse(token);
32 marks.push_back(mc);
33 debugs(28, 7, "added " << mc);
653d9927
A
34 }
35
36 if (marks.empty()) {
37 throw TexcHere(ToSBuf("acl ", typeString(), " requires at least one mark"));
38 }
39}
40
41int
42Acl::ConnMark::match(ACLChecklist *cl)
43{
44 const auto *checklist = Filled(cl);
244da4ad 45 const auto connmark = checklist->conn()->clientConnection->nfConnmark;
653d9927
A
46
47 for (const auto &m : marks) {
244da4ad 48 if (m.matches(connmark)) {
653d9927
A
49 debugs(28, 5, "found " << m << " matching " << asHex(connmark));
50 return 1;
51 }
52 debugs(28, 7, "skipped " << m << " mismatching " << asHex(connmark));
53 }
54 return 0;
55}
56
57SBufList
58Acl::ConnMark::dump() const
59{
60 SBufList sl;
61 for (const auto &m : marks) {
62 sl.push_back(ToSBuf(m));
63 }
64 return sl;
65}
66
67char const *
68Acl::ConnMark::typeString() const
69{
244da4ad 70 return "client_connection_mark";
653d9927
A
71}
72