NfMarkConfig.h
Go to the documentation of this file.
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 #ifndef SQUID_SRC_IP_NFMARKCONFIG_H
10 #define SQUID_SRC_IP_NFMARKCONFIG_H
11 
12 #include "ip/forward.h"
13 
14 #include <iosfwd>
15 
16 class SBuf;
17 
18 namespace Ip
19 {
20 
23 {
24 public:
28  NfMarkConfig(nfmark_t mark_val, nfmark_t mask_val): mark(mark_val), mask(mask_val) {}
29 
31  static NfMarkConfig Parse(const SBuf &token);
33  bool matches(const nfmark_t m) const { return (m & mask) == mark; }
35  bool isEmpty() const { return mark == 0; }
37  bool hasMask() const { return mask != 0xffffffff; }
41  nfmark_t applyToMark(nfmark_t m) const;
42 
44  nfmark_t mask = 0xffffffff;
45 };
46 
47 std::ostream &operator <<(std::ostream &, NfMarkConfig);
48 
49 } // namespace Ip
50 
51 #endif /* SQUID_SRC_IP_NFMARKCONFIG_H */
52 
bool isEmpty() const
whether the netfilter mark is unset
Definition: NfMarkConfig.h:35
Definition: SBuf.h:93
bool matches(const nfmark_t m) const
whether the 'm' matches the configured mark/mask
Definition: NfMarkConfig.h:33
static NfMarkConfig Parse(const SBuf &token)
parses a token and returns an object, expects a "mark[/mask]" format
Definition: NfMarkConfig.cc:32
uint32_t nfmark_t
Definition: forward.h:26
std::ostream & operator<<(std::ostream &os, const std::optional< Address > &optional)
Definition: Xaction.cc:140
Definition: Xaction.cc:137
a netfilter mark/mask pair
Definition: NfMarkConfig.h:22
bool hasMask() const
whether the mask is set
Definition: NfMarkConfig.h:37
NfMarkConfig(nfmark_t mark_val, nfmark_t mask_val)
creates an object with specified mark and mask
Definition: NfMarkConfig.h:28
nfmark_t applyToMark(nfmark_t m) const
Definition: NfMarkConfig.cc:46
NfMarkConfig()
creates an empty object
Definition: NfMarkConfig.h:26

 

Introduction

Documentation

Support

Miscellaneous