]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ip/QosConfig.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / ip / QosConfig.h
index b8df06c196bdf37f7da6b04235f3091d6b248471..a288f7f5d608fad5518f3ee9625ba789938258a8 100644 (file)
@@ -1,24 +1,56 @@
+/*
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
 #ifndef SQUID_QOSCONFIG_H
 #define SQUID_QOSCONFIG_H
 
+#include "acl/forward.h"
 #include "hier_code.h"
 #include "ip/forward.h"
 
 #if HAVE_LIBNETFILTER_CONNTRACK_LIBNETFILTER_CONNTRACK_H
 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
 #endif
-
 #if HAVE_LIBNETFILTER_CONNTRACK_LIBNETFILTER_CONNTRACK_TCP_H
 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
 #endif
-
-#if HAVE_LIMITS
 #include <limits>
-#endif
 
-// Forward-declaration
 class fde;
 
+// TODO: move to new ACL framework
+class acl_tos
+{
+    CBDATA_CLASS(acl_tos);
+
+public:
+    acl_tos() : next(NULL), aclList(NULL), tos(0) {}
+    ~acl_tos();
+
+    acl_tos *next;
+    ACLList *aclList;
+    tos_t tos;
+};
+
+// TODO: move to new ACL framework
+class acl_nfmark
+{
+    CBDATA_CLASS(acl_nfmark);
+
+public:
+    acl_nfmark() : next(NULL), aclList(NULL), nfmark(0) {}
+    ~acl_nfmark();
+
+    acl_nfmark *next;
+    ACLList *aclList;
+    nfmark_t nfmark;
+};
+
 namespace Ip
 {
 
@@ -105,6 +137,14 @@ int doNfmarkLocalHit(const Comm::ConnectionPointer &conn);
 */
 _SQUID_INLINE_ int setSockTos(const Comm::ConnectionPointer &conn, tos_t tos);
 
+/**
+* The low level variant of setSockTos function to set TOS value of packets.
+* Avoid if you can use the Connection-based setSockTos().
+* @param fd Descriptor of socket to set the TOS for
+* @param type The socket family, AF_INET or AF_INET6
+*/
+_SQUID_INLINE_ int setSockTos(const int fd, tos_t tos, int type);
+
 /**
 * Function to set the netfilter mark value of packets. Sets the value on the
 * socket which then gets copied to the packets. Called from Ip::Qos::doNfmarkLocalMiss
@@ -112,6 +152,14 @@ _SQUID_INLINE_ int setSockTos(const Comm::ConnectionPointer &conn, tos_t tos);
 */
 _SQUID_INLINE_ int setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark);
 
+/**
+* The low level variant of setSockNfmark function to set the netfilter mark
+* value of packets.
+* Avoid if you can use the Connection-based setSockNfmark().
+* @param fd Descriptor of socket to set the mark for
+*/
+_SQUID_INLINE_ int setSockNfmark(const int fd, nfmark_t mark);
+
 /**
  * QOS configuration class. Contains all the parameters for QOS functions as well
  * as functions to check whether either TOS or MARK QOS is enabled.
@@ -121,7 +169,7 @@ class Config
 public:
 
     Config();
-    ~Config() {};
+    ~Config() {}
 
     void parseConfigLine();
 
@@ -158,15 +206,17 @@ public:
     tos_t tosSiblingHit;                ///< TOS value to apply to hits from siblings
     tos_t tosParentHit;                 ///< TOS value to apply to hits from parent
     tos_t tosMiss;                      ///< TOS value to apply to cache misses
+    tos_t tosMissMask;                  ///< Mask for TOS value to apply to cache misses. Applied to the tosMiss value.
     bool preserveMissTos;               ///< Whether to preserve the TOS value of the inbound packet for misses
-    tos_t preserveMissTosMask;          ///< The mask to apply when preserving the TOS of misses
+    tos_t preserveMissTosMask;          ///< The mask to apply when preserving the TOS of misses. Applies to preserved value from upstream.
 
     nfmark_t markLocalHit;              ///< Netfilter mark value to apply to local cache hits
     nfmark_t markSiblingHit;            ///< Netfilter mark value to apply to hits from siblings
     nfmark_t markParentHit;             ///< Netfilter mark value to apply to hits from parent
     nfmark_t markMiss;                  ///< Netfilter mark value to apply to cache misses
+    nfmark_t markMissMask;              ///< Mask for netfilter mark value to apply to cache misses. Applied to the markMiss value.
     bool preserveMissMark;              ///< Whether to preserve netfilter mark value of inbound connection
-    nfmark_t preserveMissMarkMask;      ///< The mask to apply when preserving the netfilter mark of misses
+    nfmark_t preserveMissMarkMask;      ///< The mask to apply when preserving the netfilter mark of misses. Applied to preserved value from upstream.
 
     acl_tos *tosToServer;               ///< The TOS that packets to the web server should be marked with, based on ACL
     acl_tos *tosToClient;               ///< The TOS that packets to the client should be marked with, based on ACL
@@ -179,13 +229,13 @@ public:
 extern Config TheConfig;
 
 /* legacy parser access wrappers */
-#define parse_QosConfig(X)     (X)->parseConfigLine()
+#define parse_QosConfig(X)  (X)->parseConfigLine()
 #define free_QosConfig(X)
 #define dump_QosConfig(e,n,X) do { \
-               char temp[256]; /* random number. change as needed. max config line length. */ \
-               (X).dumpConfigLine(temp,n); \
-               storeAppendPrintf(e, "%s", temp); \
-       } while(0);
+        char temp[256]; /* random number. change as needed. max config line length. */ \
+        (X).dumpConfigLine(temp,n); \
+            storeAppendPrintf(e, "%s", temp); \
+    } while(0);
 
 } // namespace Qos
 
@@ -196,3 +246,4 @@ extern Config TheConfig;
 #endif
 
 #endif /* SQUID_QOSCONFIG_H */
+