]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ip/Qos.cci
Author: Andrew Beverley <andy@andybev.com>
[thirdparty/squid.git] / src / ip / Qos.cci
1 /* Inline QOS functions */
2
3 int
4 Ip::Qos::setSockTos(int fd, tos_t tos)
5 {
6 #ifdef IP_TOS
7 int x = setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos_t));
8 if (x < 0)
9 debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IP_TOS) on FD " << fd << ": " << xstrerror());
10 return x;
11 #else
12 debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IP_TOS) not supported on this platform");
13 return -1;
14 #endif
15 }
16
17 int
18 Ip::Qos::setSockNfmark(int fd, nfmark_t mark)
19 {
20 #if SO_MARK
21 int x = setsockopt(fd, SOL_SOCKET, SO_MARK, &mark, sizeof(nfmark_t));
22 if (x < 0)
23 debugs(50, 2, "setSockNfmark: setsockopt(SO_MARK) on FD " << fd << ": " << xstrerror());
24 return x;
25 #else
26 debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(SO_MARK) not supported on this platform");
27 return -1;
28 #endif
29 }
30
31 bool
32 Ip::Qos::Config::isHitTosActive() const
33 {
34 return (tosLocalHit || tosSiblingHit || tosParentHit || tosMiss || preserveMissTos);
35 }
36
37 bool
38 Ip::Qos::Config::isHitNfmarkActive() const
39 {
40 return (markLocalHit || markSiblingHit || markParentHit || markMiss || preserveMissMark);
41 }
42
43 bool
44 Ip::Qos::Config::isAclNfmarkActive() const
45 {
46 acl_nfmark * nfmarkAcls [] = { nfmarkToServer, nfmarkToClient };
47
48 for (int i=0; i<2; i++) {
49 while (nfmarkAcls[i]) {
50 acl_nfmark *l = nfmarkAcls[i];
51 if (l->nfmark > 0)
52 return true;
53 nfmarkAcls[i] = l->next;
54 }
55 }
56
57 return false;
58 }
59
60 bool
61 Ip::Qos::Config::isAclTosActive() const
62 {
63 acl_tos * tosAcls [] = { tosToServer, tosToClient };
64
65 for (int i=0; i<2; i++) {
66 while (tosAcls[i]) {
67 acl_tos *l = tosAcls[i];
68 if (l->tos > 0)
69 return true;
70 tosAcls[i] = l->next;
71 }
72 }
73
74 return false;
75 }