]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ip/NfMarkConfig.h
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_NFMARKCONFIG_H
10 #define SQUID_NFMARKCONFIG_H
12 #include "ip/forward.h"
19 /// a netfilter mark/mask pair
23 /// creates an empty object
25 /// creates an object with specified mark and mask
26 NfMarkConfig(nfmark_t mark_val
, nfmark_t mask_val
): mark(mark_val
), mask(mask_val
) {}
28 /// parses a token and returns an object, expects a "mark[/mask]" format
29 static NfMarkConfig
Parse(const SBuf
&token
);
30 /// whether the 'm' matches the configured mark/mask
31 bool matches(const nfmark_t m
) const { return (m
& mask
) == mark
; }
32 /// whether the netfilter mark is unset
33 bool isEmpty() const { return mark
== 0; }
34 /// whether the mask is set
35 bool hasMask() const { return mask
!= 0xffffffff; }
36 /// Applies configured mark/mask to previously set mark (m).
37 /// m is ANDed with the negated mask and then ORed with the configured mark.
38 /// \returns new mark. This is similar to what iptables --set-mark does.
39 nfmark_t
applyToMark(nfmark_t m
) const;
42 nfmark_t mask
= 0xffffffff;
45 std::ostream
&operator <<(std::ostream
&, NfMarkConfig
);
49 #endif // SQUID_NFMARKCONFIG_H