1 /* Inline QOS functions */
2 #include "comm/Connection.h"
6 Ip::Qos::setSockTos(const Comm::ConnectionPointer &conn, tos_t tos)
8 // Bug 3731: FreeBSD produces 'invalid option'
9 // unless we pass it a 32-bit variable storing 8-bits of data.
10 // NP: it is documented as 'int' for all systems, even those like Linux which accept 8-bit char
11 // so we convert to a int before setting.
14 if (conn->remote.isIPv4()) {
16 int x = setsockopt(conn->fd, IPPROTO_IP, IP_TOS, &bTos, sizeof(bTos));
18 debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IP_TOS) on " << conn << ": " << xstrerror());
23 debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IP_TOS) not supported on this platform");
27 } else { // if (conn->remote.isIPv6()) {
28 #if defined(IPV6_TCLASS)
29 int x = setsockopt(conn->fd, IPPROTO_IPV6, IPV6_TCLASS, &bTos, sizeof(bTos));
31 debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IPV6_TCLASS) on " << conn << ": " << xstrerror());
36 debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IPV6_TCLASS) not supported on this platform");
41 /* CANNOT REACH HERE */
45 Ip::Qos::setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark)
47 #if SO_MARK && USE_LIBCAP
48 int x = setsockopt(conn->fd, SOL_SOCKET, SO_MARK, &mark, sizeof(nfmark_t));
50 debugs(50, 2, "setSockNfmark: setsockopt(SO_MARK) on " << conn << ": " << xstrerror());
55 debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(SO_MARK) not supported on this platform");
58 debugs(50, DBG_IMPORTANT, "WARNING: Netfilter marking disabled (netfilter marking requires build with LIBCAP)");
64 Ip::Qos::Config::isHitTosActive() const
66 return (tosLocalHit || tosSiblingHit || tosParentHit || tosMiss || preserveMissTos);
70 Ip::Qos::Config::isHitNfmarkActive() const
72 return (markLocalHit || markSiblingHit || markParentHit || markMiss || preserveMissMark);
76 Ip::Qos::Config::isAclNfmarkActive() const
78 acl_nfmark * nfmarkAcls [] = { nfmarkToServer, nfmarkToClient };
80 for (int i=0; i<2; ++i) {
81 while (nfmarkAcls[i]) {
82 acl_nfmark *l = nfmarkAcls[i];
85 nfmarkAcls[i] = l->next;
93 Ip::Qos::Config::isAclTosActive() const
95 acl_tos * tosAcls [] = { tosToServer, tosToClient };
97 for (int i=0; i<2; ++i) {
99 acl_tos *l = tosAcls[i];
102 tosAcls[i] = l->next;