]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: remove ip/Qos.cci file
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 8 Jan 2017 02:18:32 +0000 (15:18 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 8 Jan 2017 02:18:32 +0000 (15:18 +1300)
... moving its content to ip/QosConfig.cc

Also, move the stub file to src/tests/stub_libip.cc and update to use
tests/STUB.h interface.

src/ip/Makefile.am
src/ip/Qos.cci [deleted file]
src/ip/QosConfig.cc
src/ip/QosConfig.h
src/ip/stubQosConfig.cc [deleted file]
src/tests/Stub.list
src/tests/stub_libip.cc [new file with mode: 0644]

index 592dadf875cd7a2fa18612c4fc40e90ecfeebbc0..8a2f38ddebe317e402ec684e48ddc28d08a16f19 100644 (file)
@@ -18,6 +18,5 @@ libip_la_SOURCES = \
        Intercept.cc \
        QosConfig.h \
        QosConfig.cc \
-       Qos.cci \
        tools.cc \
        tools.h
diff --git a/src/ip/Qos.cci b/src/ip/Qos.cci
deleted file mode 100644 (file)
index 17e9007..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.
- */
-
-/* Inline QOS functions */
-#include "comm/Connection.h"
-#include "Debug.h"
-
-int
-Ip::Qos::setSockTos(const int fd, tos_t tos, int type)
-{
-    // Bug 3731: FreeBSD produces 'invalid option'
-    // unless we pass it a 32-bit variable storing 8-bits of data.
-    // NP: it is documented as 'int' for all systems, even those like Linux which accept 8-bit char
-    //     so we convert to a int before setting.
-    int bTos = tos;
-
-    debugs(50, 3, "for FD " << fd << " to " << bTos);
-
-    if (type == AF_INET) {
-#if defined(IP_TOS)
-        const int x = setsockopt(fd, IPPROTO_IP, IP_TOS, &bTos, sizeof(bTos));
-        if (x < 0) {
-            int xerrno = errno;
-            debugs(50, 2, "setsockopt(IP_TOS) on " << fd << ": " << xstrerr(xerrno));
-        }
-        return x;
-#else
-        debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IP_TOS) not supported on this platform");
-        return -1;
-#endif
-    } else { // type == AF_INET6
-#if defined(IPV6_TCLASS)
-        const int x = setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &bTos, sizeof(bTos));
-        if (x < 0) {
-            int xerrno = errno;
-            debugs(50, 2, "setsockopt(IPV6_TCLASS) on " << fd << ": " << xstrerr(xerrno));
-        }
-        return x;
-#else
-        debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IPV6_TCLASS) not supported on this platform");
-        return -1;
-#endif
-    }
-
-    /* CANNOT REACH HERE */
-}
-
-int
-Ip::Qos::setSockTos(const Comm::ConnectionPointer &conn, tos_t tos)
-{
-    const int x = Ip::Qos::setSockTos(conn->fd, tos, conn->remote.isIPv4() ? AF_INET : AF_INET6);
-    conn->tos = (x >= 0) ? tos : 0;
-    return x;
-}
-
-int
-Ip::Qos::setSockNfmark(const int fd, nfmark_t mark)
-{
-#if SO_MARK && USE_LIBCAP
-    debugs(50, 3, "for FD " << fd << " to " << mark);
-    const int x = setsockopt(fd, SOL_SOCKET, SO_MARK, &mark, sizeof(nfmark_t));
-    if (x < 0) {
-        int xerrno = errno;
-        debugs(50, 2, "setsockopt(SO_MARK) on " << fd << ": " << xstrerr(xerrno));
-    }
-    return x;
-#elif USE_LIBCAP
-    debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(SO_MARK) not supported on this platform");
-    return -1;
-#else
-    debugs(50, DBG_IMPORTANT, "WARNING: Netfilter marking disabled (netfilter marking requires build with LIBCAP)");
-    return -1;
-#endif
-}
-
-int
-Ip::Qos::setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark)
-{
-    const int x = Ip::Qos::setSockNfmark(conn->fd, mark);
-    conn->nfmark = (x >= 0) ? mark : 0;
-    return x;
-}
-
-bool
-Ip::Qos::Config::isHitTosActive() const
-{
-    return (tosLocalHit || tosSiblingHit || tosParentHit || tosMiss || preserveMissTos);
-}
-
-bool
-Ip::Qos::Config::isHitNfmarkActive() const
-{
-    return (markLocalHit || markSiblingHit || markParentHit || markMiss || preserveMissMark);
-}
-
-bool
-Ip::Qos::Config::isAclNfmarkActive() const
-{
-    acl_nfmark * nfmarkAcls [] = { nfmarkToServer, nfmarkToClient };
-
-    for (int i=0; i<2; ++i) {
-        while (nfmarkAcls[i]) {
-            acl_nfmark *l = nfmarkAcls[i];
-            if (l->nfmark > 0)
-                return true;
-            nfmarkAcls[i] = l->next;
-        }
-    }
-
-    return false;
-}
-
-bool
-Ip::Qos::Config::isAclTosActive() const
-{
-    acl_tos * tosAcls [] = { tosToServer, tosToClient };
-
-    for (int i=0; i<2; ++i) {
-        while (tosAcls[i]) {
-            acl_tos *l = tosAcls[i];
-            if (l->tos > 0)
-                return true;
-            tosAcls[i] = l->next;
-        }
-    }
-
-    return false;
-}
-
index b8ca446bfb3969534139eafe1e8023d5b682434f..d84de2af4cef13567f17f62f757fb772c21d9ee2 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #include "squid.h"
-
 #include "acl/Gadgets.h"
 #include "cache_cf.h"
 #include "comm/Connection.h"
@@ -451,7 +450,113 @@ Ip::Qos::Config::dumpConfigLine(char *entry, const char *name) const
     }
 }
 
-#if !_USE_INLINE_
-#include "Qos.cci"
+int
+Ip::Qos::setSockTos(const int fd, tos_t tos, int type)
+{
+    // Bug 3731: FreeBSD produces 'invalid option'
+    // unless we pass it a 32-bit variable storing 8-bits of data.
+    // NP: it is documented as 'int' for all systems, even those like Linux which accept 8-bit char
+    //     so we convert to a int before setting.
+    int bTos = tos;
+
+    debugs(50, 3, "for FD " << fd << " to " << bTos);
+
+    if (type == AF_INET) {
+#if defined(IP_TOS)
+        const int x = setsockopt(fd, IPPROTO_IP, IP_TOS, &bTos, sizeof(bTos));
+        if (x < 0) {
+            int xerrno = errno;
+            debugs(50, 2, "setsockopt(IP_TOS) on " << fd << ": " << xstrerr(xerrno));
+        }
+        return x;
+#else
+        debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IP_TOS) not supported on this platform");
+        return -1;
 #endif
+    } else { // type == AF_INET6
+#if defined(IPV6_TCLASS)
+        const int x = setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &bTos, sizeof(bTos));
+        if (x < 0) {
+            int xerrno = errno;
+            debugs(50, 2, "setsockopt(IPV6_TCLASS) on " << fd << ": " << xstrerr(xerrno));
+        }
+        return x;
+#else
+        debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IPV6_TCLASS) not supported on this platform");
+        return -1;
+#endif
+    }
+
+    /* CANNOT REACH HERE */
+}
+
+int
+Ip::Qos::setSockTos(const Comm::ConnectionPointer &conn, tos_t tos)
+{
+    const int x = Ip::Qos::setSockTos(conn->fd, tos, conn->remote.isIPv4() ? AF_INET : AF_INET6);
+    conn->tos = (x >= 0) ? tos : 0;
+    return x;
+}
+
+int
+Ip::Qos::setSockNfmark(const int fd, nfmark_t mark)
+{
+#if SO_MARK && USE_LIBCAP
+    debugs(50, 3, "for FD " << fd << " to " << mark);
+    const int x = setsockopt(fd, SOL_SOCKET, SO_MARK, &mark, sizeof(nfmark_t));
+    if (x < 0) {
+        int xerrno = errno;
+        debugs(50, 2, "setsockopt(SO_MARK) on " << fd << ": " << xstrerr(xerrno));
+    }
+    return x;
+#elif USE_LIBCAP
+    debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(SO_MARK) not supported on this platform");
+    return -1;
+#else
+    debugs(50, DBG_IMPORTANT, "WARNING: Netfilter marking disabled (netfilter marking requires build with LIBCAP)");
+    return -1;
+#endif
+}
+
+int
+Ip::Qos::setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark)
+{
+    const int x = Ip::Qos::setSockNfmark(conn->fd, mark);
+    conn->nfmark = (x >= 0) ? mark : 0;
+    return x;
+}
+
+bool
+Ip::Qos::Config::isAclNfmarkActive() const
+{
+    acl_nfmark * nfmarkAcls [] = { nfmarkToServer, nfmarkToClient };
+
+    for (int i=0; i<2; ++i) {
+        while (nfmarkAcls[i]) {
+            acl_nfmark *l = nfmarkAcls[i];
+            if (l->nfmark > 0)
+                return true;
+            nfmarkAcls[i] = l->next;
+        }
+    }
+
+    return false;
+}
+
+bool
+Ip::Qos::Config::isAclTosActive() const
+{
+    acl_tos * tosAcls [] = { tosToServer, tosToClient };
+
+    for (int i=0; i<2; ++i) {
+        while (tosAcls[i]) {
+            acl_tos *l = tosAcls[i];
+            if (l->tos > 0)
+                return true;
+            tosAcls[i] = l->next;
+        }
+    }
+
+    return false;
+}
 
index a288f7f5d608fad5518f3ee9625ba789938258a8..209d41cc2f0900c93b2949a15cc2ea6c172da8d6 100644 (file)
@@ -135,7 +135,7 @@ int doNfmarkLocalHit(const Comm::ConnectionPointer &conn);
 * which then gets copied to the packets.
 * @param conn Descriptor of socket to set the TOS for
 */
-_SQUID_INLINE_ int setSockTos(const Comm::ConnectionPointer &conn, tos_t tos);
+int setSockTos(const Comm::ConnectionPointer &conn, tos_t tos);
 
 /**
 * The low level variant of setSockTos function to set TOS value of packets.
@@ -143,14 +143,14 @@ _SQUID_INLINE_ int setSockTos(const Comm::ConnectionPointer &conn, tos_t tos);
 * @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);
+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
 * @param conn Descriptor of socket to set the mark for
 */
-_SQUID_INLINE_ int setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark);
+int setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark);
 
 /**
 * The low level variant of setSockNfmark function to set the netfilter mark
@@ -158,7 +158,7 @@ _SQUID_INLINE_ int setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t m
 * 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);
+int setSockNfmark(const int fd, nfmark_t mark);
 
 /**
  * QOS configuration class. Contains all the parameters for QOS functions as well
@@ -183,10 +183,14 @@ public:
     void dumpConfigLine(char *entry, const char *name) const;
 
     /// Whether we should modify TOS flags based on cache hits and misses.
-    _SQUID_INLINE_ bool isHitTosActive() const;
+    bool isHitTosActive() const {
+        return (tosLocalHit || tosSiblingHit || tosParentHit || tosMiss || preserveMissTos);
+    }
 
     /// Whether we should modify netfilter marks based on cache hits and misses.
-    _SQUID_INLINE_ bool isHitNfmarkActive() const;
+    bool isHitNfmarkActive() const {
+        return (markLocalHit || markSiblingHit || markParentHit || markMiss || preserveMissMark);
+    }
 
     /**
     * Iterates through any outgoing_nfmark or clientside_nfmark configuration parameters
@@ -194,13 +198,13 @@ public:
     * This function is used on initialisation to define capabilities required (Netfilter
     * marking requires CAP_NET_ADMIN).
     */
-    _SQUID_INLINE_ bool isAclNfmarkActive() const;
+    bool isAclNfmarkActive() const;
 
     /**
     * Iterates through any outgoing_tos or clientside_tos configuration parameters
     * to find out if packets should be marked with TOS flags.
     */
-    _SQUID_INLINE_ bool isAclTosActive() const;
+    bool isAclTosActive() const;
 
     tos_t tosLocalHit;                  ///< TOS value to apply to local cache hits
     tos_t tosSiblingHit;                ///< TOS value to apply to hits from siblings
@@ -241,9 +245,5 @@ extern Config TheConfig;
 
 } // namespace Ip
 
-#if _USE_INLINE_
-#include "Qos.cci"
-#endif
-
 #endif /* SQUID_QOSCONFIG_H */
 
diff --git a/src/ip/stubQosConfig.cc b/src/ip/stubQosConfig.cc
deleted file mode 100644 (file)
index 6d73a16..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.
- */
-
-#include "squid.h"
-
-#include "ip/QosConfig.h"
-#include "Store.h"
-
-void
-Ip::Qos::getTosFromServer(fde *clientFde, const int server_fd)
-{
-#if USE_QOS_TOS
-    fatal ("Not implemented");
-#endif
-}
-
-void Ip::Qos::getNfmarkFromServer(const fde *clientFde, const fde *servFde, const int server_fd)
-{
-#if USE_QOS_NFMARK
-    fatal ("Not implemented");
-#endif
-}
-
-#if USE_QOS_NFMARK
-int
-Ip::Qos::GetNfMarkCallback(enum nf_conntrack_msg_type type,
-                           struct nf_conntrack *ct,
-                           void *data)
-{
-    fatal ("Not implemented");
-}
-#endif
-
-tos_t
-Ip::Qos::doTosLocalMiss(const int fd, const hier_code hierCode) const
-{
-    fatal ("Not implemented");
-}
-
-int
-Ip::Qos::doNfmarkLocalMiss(const int fd, const hier_code hierCode) const
-{
-    fatal ("Not implemented");
-}
-
-int
-Ip::Qos::doTosLocalHit(const int fd) const
-{
-    fatal ("Not implemented");
-}
-
-int
-Ip::Qos::doNfmarkLocalHit(const int fd) const
-{
-    fatal ("Not implemented");
-}
-
-Ip::Qos::Config()
-{
-    fatal ("Not implemented");
-}
-
-Ip::Qos::~Config()
-{
-    fatal ("Not implemented");
-}
-
-void
-Ip::Qos::parseConfigLine()
-{
-    fatal ("Not implemented");
-}
-
-void
-Ip::Qos::dumpConfigLine(char *entry, const char *name)
-{
-    fatal ("Not implemented");
-}
-
-#if !_USE_INLINE_
-#include "Qos.cci"
-#endif
-
index 6e3b2b272564bfa54d46b4e311a3101152b4e4f6..73904764d724599e0c8e0d29918d1d70c97a090c 100644 (file)
@@ -48,6 +48,7 @@ STUB_SOURCE= tests/STUB.h \
        tests/stub_libeui.cc \
        tests/stub_libformat.cc \
        tests/stub_libicmp.cc \
+       tests/stub_libip.cc \
        tests/stub_liblog.cc \
        tests/stub_libmem.cc \
        tests/stub_libmgr.cc \
diff --git a/src/tests/stub_libip.cc b/src/tests/stub_libip.cc
new file mode 100644 (file)
index 0000000..b19a260
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include "squid.h"
+#include "Store.h"
+
+#define STUB_API "ip/libip.la"
+#include "tests/STUB.h"
+
+#include "ip/QosConfig.h"
+namespace Ip
+{
+namespace Qos
+{
+void getTosFromServer(fde *, const int) {
+#if USE_QOS_TOS
+    STUB
+#endif
+}
+void getNfmarkFromServer(const fde *, const fde *, const int) {
+#if USE_QOS_NFMARK
+    STUB
+#endif
+}
+#if USE_QOS_NFMARK
+int GetNfMarkCallback(enum nf_conntrack_msg_type, struct nf_conntrack *, void *) STUB_RETVAL(-1)
+#endif
+tos_t doTosLocalMiss(const int, const hier_code) STUB_RETVAL(-1)
+int doNfmarkLocalMiss(const int, const hier_code) STUB_RETVAL(-1)
+int doTosLocalHit(const int) STUB_RETVAL(-1)
+int doNfmarkLocalHit(const int) STUB_RETVAL(-1)
+void parseConfigLine() STUB
+void dumpConfigLine(char *, const char *) STUB
+
+Config::Config() {STUB}
+bool Config::isAclNfmarkActive() const STUB_RETVAL(false)
+bool Config::isAclTosActive() const STUB_RETVAL(false)
+}
+}
+