ConnMark.cc
Go to the documentation of this file.
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 
19 bool
21 {
22  return false;
23 }
24 
25 void
27 {
28  while (const char *t = ConfigParser::strtokFile()) {
29  SBuf token(t);
30  Parser::Tokenizer tokenizer(token);
31  const auto mc = Ip::NfMarkConfig::Parse(token);
32  marks.push_back(mc);
33  debugs(28, 7, "added " << mc);
34  }
35 
36  if (marks.empty()) {
37  throw TexcHere(ToSBuf("acl ", typeString(), " requires at least one mark"));
38  }
39 }
40 
41 int
43 {
44  const auto *checklist = Filled(cl);
45  const auto connmark = checklist->conn()->clientConnection->nfConnmark;
46 
47  for (const auto &m : marks) {
48  if (m.matches(connmark)) {
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 
59 {
60  SBufList sl;
61  for (const auto &m : marks) {
62  sl.push_back(ToSBuf(m));
63  }
64  return sl;
65 }
66 
67 char const *
69 {
70  return "client_connection_mark";
71 }
72 
virtual void parse() override
parses node represenation in squid.conf; dies on failures
Definition: ConnMark.cc:26
Definition: SBuf.h:86
ACLFilledChecklist * Filled(ACLChecklist *checklist)
convenience and safety wrapper for dynamic_cast<ACLFilledChecklist*>
virtual int match(ACLChecklist *checklist) override
Matches the actual data in checklist against this ACL.
Definition: ConnMark.cc:42
static NfMarkConfig Parse(const SBuf &token)
parses a token and returns an object, expects a "mark[/mask]" format
Definition: NfMarkConfig.cc:32
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:124
virtual char const * typeString() const override
Definition: ConnMark.cc:68
AsHex< Integer > asHex(const Integer n)
a helper to ease AsHex object creation
Definition: Debug.h:275
std::list< SBuf > SBufList
Definition: forward.h:22
SBuf ToSBuf(Args &&...args)
slowly stream-prints all arguments into a freshly allocated SBuf
Definition: Stream.h:124
static char * strtokFile()
Definition: ConfigParser.cc:82
virtual bool empty() const override
Definition: ConnMark.cc:20
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
Definition: TextException.h:55
virtual SBufList dump() const override
Definition: ConnMark.cc:58

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors