]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/ConnMark.cc
Bug 5428: Warn if pkg-config is not found (#1902)
[thirdparty/squid.git] / src / acl / ConnMark.cc
1 /*
2 * Copyright (C) 1996-2023 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 "base/IoManip.h"
15 #include "client_side.h"
16 #include "debug/Stream.h"
17 #include "http/Stream.h"
18 #include "sbuf/Stream.h"
19
20 bool
21 Acl::ConnMark::empty() const
22 {
23 return false;
24 }
25
26 void
27 Acl::ConnMark::parse()
28 {
29 while (const char *t = ConfigParser::strtokFile()) {
30 SBuf token(t);
31 Parser::Tokenizer tokenizer(token);
32 const auto mc = Ip::NfMarkConfig::Parse(token);
33 marks.push_back(mc);
34 debugs(28, 7, "added " << mc);
35 }
36
37 if (marks.empty()) {
38 throw TexcHere(ToSBuf("acl ", typeString(), " requires at least one mark"));
39 }
40 }
41
42 int
43 Acl::ConnMark::match(ACLChecklist *cl)
44 {
45 const auto *checklist = Filled(cl);
46 const auto conn = checklist->conn();
47
48 if (conn && conn->clientConnection) {
49 const auto connmark = conn->clientConnection->nfConnmark;
50
51 for (const auto &m : marks) {
52 if (m.matches(connmark)) {
53 debugs(28, 5, "found " << m << " matching 0x" << asHex(connmark));
54 return 1;
55 }
56 debugs(28, 7, "skipped " << m << " mismatching 0x" << asHex(connmark));
57 }
58 } else {
59 debugs(28, 7, "fails: no client connection");
60 }
61
62 return 0;
63 }
64
65 SBufList
66 Acl::ConnMark::dump() const
67 {
68 SBufList sl;
69 for (const auto &m : marks) {
70 sl.push_back(ToSBuf(m));
71 }
72 return sl;
73 }
74
75 char const *
76 Acl::ConnMark::typeString() const
77 {
78 return "client_connection_mark";
79 }
80