]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #741 in SNORT/snort3 from macros to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 8 Dec 2016 03:50:36 +0000 (22:50 -0500)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 8 Dec 2016 03:50:36 +0000 (22:50 -0500)
Squashed commit of the following:

commit dd8de11b48dd18c5dbbd8d0d093b40028771b296
Author: Michael Altizer <mialtize@cisco.com>
Date:   Wed Dec 7 16:44:33 2016 -0500

    build: Rework key structure padding guard macros

23 files changed:
extra/src/inspectors/http_server/ips_http_header.cc
src/detection/tag.cc
src/file_api/file_cache.h
src/file_api/file_enforcer.h
src/filters/detection_filter.cc
src/filters/rate_filter.cc
src/filters/sfrf.cc
src/filters/sfrf.h
src/filters/sfthd.cc
src/filters/sfthd.h
src/filters/sfthd_test.cc
src/filters/sfthreshold.cc
src/flow/flow_key.cc
src/flow/flow_key.h
src/network_inspectors/appid/host_port_app_cache.cc
src/network_inspectors/appid/service_state.cc
src/network_inspectors/port_scan/ps_detect.cc
src/service_inspectors/dce_rpc/ips_dce_iface.cc
src/service_inspectors/dce_rpc/ips_dce_opnum.cc
src/service_inspectors/dce_rpc/ips_dce_stub_data.cc
src/utils/CMakeLists.txt
src/utils/Makefile.am
src/utils/cpp_macros.h [new file with mode: 0644]

index f5f1b020a8661dec3843c0b83504e4dae53e6ed9..35d01479eeb2c9d1fc1991192e91f79a0108d307 100644 (file)
 
 #include <string>
 
-#include "main/snort_types.h"
-#include "main/snort_debug.h"
-#include "profiler/profiler.h"
-#include "flow/flow.h"
 #include "detection/detection_defines.h"
-#include "framework/ips_option.h"
 #include "framework/cursor.h"
-#include "framework/inspector.h"
+#include "framework/ips_option.h"
 #include "framework/module.h"
+#include "hash/sfhashfcn.h"
+#include "profiler/profiler_defs.h"
 #include "protocols/packet.h"
 
 using namespace std;
index abd00ca265237d0f1505822e21d479b28c680268..6819953ccf8a0ed1fcebc1a092583048e3fd8f91 100644 (file)
@@ -56,8 +56,7 @@
 /*  D A T A   S T R U C T U R E S  **********************************/
 /**Key used for identifying a session or host.
  */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
 struct tTagFlowKey
 {
     SfIp sip;  ///source IP address
@@ -67,7 +66,7 @@ struct tTagFlowKey
     uint16_t sp; ///source port
     uint16_t dp; ///destination port
 };
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
 
 /**Node identifying a session or host based tagging.
  */
index 33912895ffcf80c4c6fffad78ff89d85b010b48c..22146a31defd6b2478d94371fca04bb382ed0ccc 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "hash/sfxhash.h"
 #include "sfip/sf_ip.h"
+#include "utils/cpp_macros.h"
 
 #include "file_config.h"
 
@@ -32,8 +33,7 @@ class FileCache
 {
 public:
 // FIXIT-L Merge definition with duplicate in file_enforcer.h?
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
     struct FileHashKey
     {
         SfIp sip;
@@ -41,7 +41,7 @@ public:
         uint32_t padding;
         uint64_t file_sig;
     };
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
 
     struct FileNode
     {
index 5b28903a25dbc73264783cff756931ab9cc3520f..abac40bf8fec2cef8e8fe96bf9d94c703e7e9285 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "hash/sfxhash.h"
 #include "sfip/sf_ip.h"
+#include "utils/cpp_macros.h"
 
 #include "file_config.h"
 
@@ -52,8 +53,7 @@ public:
 
 private:
 // FIXIT-L Merge definition with duplicate in file_cache.h?
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
     struct FileHashKey
     {
         SfIp sip;
@@ -61,7 +61,7 @@ private:
         uint32_t padding;
         uint64_t file_sig;
     };
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
 
     void update_file_node(FileNode*, FileInfo*);
     FileVerdict check_verdict(Flow*, FileNode*, SFXHASH_NODE*);
index be1b6f73ac97f8a7e4cb4f2a69cc86827e8327ae..6c5e6201306c237c78be92670ac5ea62d902bc88 100644 (file)
 
 #include "detection_filter.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "filters/sfthd.h"
+#include "hash/sfxhash.h"
 #include "log/messages.h"
 #include "main/thread.h"
-#include "parser/parser.h"
 #include "utils/util.h"
 
+#include "sfthd.h"
+
 static THREAD_LOCAL SFXHASH* detection_filter_hash = NULL;
 
 DetectionFilterConfig* DetectionFilterConfigNew()
index fc141971ddacd5b077813b5c0cbe8391f43af4eb..bfd3c7fdf9351c645bb3b135d5fb80e3dc0f112c 100644 (file)
 #include "config.h"
 #endif
 
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "detection/rules.h"
+#include "detection/treenodes.h"
 #include "main/snort_config.h"
-#include "parser/parser.h"
 #include "protocols/packet.h"
-#include "sfip/sf_ip.h"
 #include "utils/util.h"
 
 #include "sfrf.h"
-#include "sfthd.h"
 
 //static int _printThresholdContext(RateFilterConfig*);
 
index ace2dae75befbfe035373ed26d4e892b391fc3d2..e1c580517fa1d36ec7804cac83269c482e2afda7 100644 (file)
 #include "config.h"
 #endif
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
 #include "detection/rules.h"
-#include "detection/treenodes.h"
-#include "utils/util.h"
-#include "utils/sflsq.h"
 #include "hash/sfghash.h"
 #include "hash/sfxhash.h"
 #include "sfip/sf_ip.h"
 #include "sfip/sf_ipvar.h"
+#include "utils/cpp_macros.h"
+#include "utils/sflsq.h"
+#include "utils/util.h"
 
 // Number of hash rows for gid 1 (rules)
 #define SFRF_GEN_ID_1_ROWS 4096
@@ -52,8 +46,7 @@
 // private data ...
 /* Key to find tracking nodes in trackingHash.
  */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
 typedef struct
 {
     ///policy identifier.
@@ -70,7 +63,7 @@ typedef struct
     SfIp ip;
     uint16_t padding;
 } tSFRFTrackingNodeKey;
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
 
 /* Tracking node for rate_filter. One node is created on fly, in tracking
  * hash for each threshold configure (identified by Tid) and source or
index 2a9f08d5da8cda8baf4e3f5b8157ad55ddb0c1d3..1799960001094558d6e564d491e34dea6538a279 100644 (file)
@@ -24,8 +24,8 @@
 
 // Implements rate_filter feature for snort
 
-#include "main/policy.h"
 #include "actions/actions.h"
+#include "main/policy.h"
 
 struct SfIp;
 
index 703a72b53fc17a58d57e0a6d11d781e4dd4bf3a6..949abca78378449fe7f6c13b8caac68ab66d83ad 100644 (file)
 #include "config.h"
 #endif
 
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <netinet/in.h>
-
-#include "sfip/sf_ip.h"
-#include "sfip/sf_ipvar.h"
-#include "utils/sflsq.h"
 #include "hash/sfghash.h"
 #include "hash/sfxhash.h"
-#include "utils/util.h"
+#include "sfip/sf_ipvar.h"
 #include "utils/dyn_array.h"
+#include "utils/sflsq.h"
+#include "utils/util.h"
 
 //  Debug Printing
 //#define THD_DEBUG
index c3116d046056a4a8d0dca482fd0d8d556d39dbf7..2b117af5bbaa157dcb9e424671e412b630aed39e 100644 (file)
 #include "config.h"
 #endif
 
-#include "utils/sflsq.h"
-#include "hash/sfghash.h"
-#include "hash/sfxhash.h"
 #include "main/policy.h"
 #include "sfip/sf_ip.h"
+#include "utils/cpp_macros.h"
+
+struct SFGHASH;
+struct SFXHASH;
+typedef struct sf_list SF_LIST;
 
 /*!
     Max GEN_ID value - Set this to the Max Used by Snort, this is used for the
@@ -95,8 +97,7 @@ typedef struct
     HASH Key to lookup and store Ip nodes. The structure now tracks thresholds for different
     policies. This destroys locality of reference and may cause poor performance.
 */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
 typedef struct
 {
     int thd_id;
@@ -113,7 +114,7 @@ typedef struct
     SfIp ip;
     uint16_t padding;
 } THD_IP_GNODE_KEY;
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
 
 /*!
     THD_NODE
index 0239b533992d49708f99bb341dd851abe676b092..1de5d0457cc0e72aea95e97fa8294a844f84d5df 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "catch/catch.hpp"
 #include "catch/unit_test.h"
+#include "hash/sfxhash.h"
 #include "parser/parse_ip.h"
 #include "sfip/sf_ip.h"
 
index b9a83f7e517851c2e29dfd360076e06e2737023b..b3f691c777821f289892dbaf816b0961443f1a84 100644 (file)
 */
 #include "sfthreshold.h"
 
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "sfthd.h"
+#include "hash/sfxhash.h"
 #include "main/snort_config.h"
 #include "utils/util.h"
-#include "parser/parser.h"
+
+#include "sfthd.h"
 
 /* Data */
 THD_STRUCT* thd_runtime = NULL;
index 9c383c1d662063aa71ce81190ac91c473233d25c..266ee07b071768e35c7f7d053d2cce6026505293 100644 (file)
 #include "config.h"
 #endif
 
+#include "hash/sfhashfcn.h"
 #include "main/snort_config.h"
-#include "utils/util.h"
-#include "sfip/sf_ip.h"
-#include "protocols/packet.h"
 #include "protocols/icmp4.h"
 #include "protocols/icmp6.h"
+#include "utils/util.h"
 
 //-------------------------------------------------------------------------
 // init foo
index ce197cad325a2d080a941f8d73c3e6682a07c3f9..0e30cb114f2206b715d4272119f1ecf61179edf2 100644 (file)
 // FlowKey is used to store Flows in the caches.  the data members are
 // sequenced to avoid void space.
 
-#include "main/snort_types.h"
-#include "hash/sfhashfcn.h"
+#include <stdint.h>
+
 #include "framework/decode_data.h"
-#include "sfip/sf_ip.h"
+#include "utils/cpp_macros.h"
+
+struct SFHASHFCN;
+struct SfIp;
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
 struct FlowKey
 {
     uint32_t   ip_l[4]; /* Low IP */
@@ -80,7 +82,7 @@ private:
         const SfIp *dstIP, uint16_t dstPort,
         uint32_t mplsId, bool order = true);
 };
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
 
 #endif
 
index 017c4b9ebda96507b0c2636d6c170e27da5827be..07fc727665d94aefb62b05568bd2f8b89a8b713d 100644 (file)
@@ -27,8 +27,7 @@
 #include "log/messages.h"
 #include "sfip/sf_ip.h"
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
 struct HostPortKey
 {
     HostPortKey()
@@ -63,7 +62,7 @@ struct HostPortKey
     IpProtocol proto;
     char padding;
 };
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
 
 THREAD_LOCAL std::map<HostPortKey, HostPortVal>* host_port_cache = nullptr;
 
index e3879cee96dba94487414568cd006a2930bd1098..96feeea87b5deccb3089876faf5c14e07ae4f19c 100644 (file)
@@ -30,8 +30,7 @@
 
 //#define DEBUG_SERVICE_STATE 1
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
 class AppIdServiceStateKey
 {
 public:
@@ -73,7 +72,7 @@ public:
     IpProtocol proto;
     char padding[3];
 };
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
 
 // FIXIT-L - no memcap on size of this table, do we need that?
 THREAD_LOCAL std::map<AppIdServiceStateKey, AppIdServiceIDState*>* service_state_cache = nullptr;
index a53a36bec4366cce9dc0561d061f32c5098f5669..b17265bb5382b9231981ba78128766854d954b38 100644 (file)
 #include "sfip/sf_ip.h"
 #include "stream/stream.h"
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
 typedef struct s_PS_HASH_KEY
 {
     int protocol;
     SfIp scanner;
     SfIp scanned;
 } PS_HASH_KEY;
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
 
 typedef struct s_PS_ALERT_CONF
 {
index dfe0820476cfdc8739ebe752336bcd57aa7cdf66..1477e5bd078b97fad1e2a27304fe6dd3627721bd 100644 (file)
@@ -26,6 +26,7 @@
 #include "framework/module.h"
 #include "framework/ips_option.h"
 #include "framework/range.h"
+#include "hash/sfhashfcn.h"
 #include "profiler/profiler.h"
 #include "target_based/snort_protocols.h"
 #include "utils/util.h"
index f97563db4c1b4a7acde04dac872e33ea425fdd37..a64c247a7dd928c8b7fcef2fe0caf1f19bffcff9 100644 (file)
@@ -22,6 +22,7 @@
 #include "detection/detection_defines.h"
 #include "framework/ips_option.h"
 #include "framework/module.h"
+#include "hash/sfhashfcn.h"
 #include "profiler/profiler.h"
 #include "utils/util.h"
 
index c1ed87261d9b65c9764481b14d98ab26b7b7c05b..c21ed1d4488d5774718f55a9fff1e5fed82677e2 100644 (file)
@@ -23,6 +23,7 @@
 #include "framework/cursor.h"
 #include "framework/ips_option.h"
 #include "framework/module.h"
+#include "hash/sfhashfcn.h"
 #include "profiler/profiler.h"
 
 #include "dce_common.h"
index 6ea5509f5a638b5a4ce1a69196da4ac94d384b66..e668423d70dc9dbf49c2bb13af828a46ab7c52ff 100644 (file)
@@ -9,6 +9,7 @@ endif ( BUILD_SNPRINTF )
 
 set( UTIL_INCLUDES
     bitop.h
+    cpp_macros.h
     dnet_header.h
     kmap.h
     safec.h
index 01a02281464625f611f75179c0c2934b10e2de6c..91310aae3196106d691333e25a779701432a88ab 100644 (file)
@@ -5,6 +5,7 @@ x_includedir = $(pkgincludedir)/utils
 
 x_include_HEADERS = \
 bitop.h \
+cpp_macros.h \
 dnet_header.h \
 kmap.h  \
 safec.h \
diff --git a/src/utils/cpp_macros.h b/src/utils/cpp_macros.h
new file mode 100644 (file)
index 0000000..3b01ef0
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef CPP_MACROS_H
+#define CPP_MACROS_H
+
+#define STRINGIFY(x) #x
+
+#if defined(__clang__) && !defined(__ICC)
+#  define PADDING_GUARD_BEGIN \
+    _Pragma(STRINGIFY( clang diagnostic push )) \
+    _Pragma(STRINGIFY( clang diagnostic warning "-Wpadded" ))
+#  define PADDING_GUARD_END \
+    _Pragma(STRINGIFY( clang diagnostic pop ))
+#elif defined(__GNUC__) && __GNUC__ > 4 && !defined(__ICC)
+#  define PADDING_GUARD_BEGIN \
+    _Pragma(STRINGIFY( GCC diagnostic push )) \
+    _Pragma(STRINGIFY( GCC diagnostic warning "-Wpadded" ))
+#  define PADDING_GUARD_END \
+    _Pragma(STRINGIFY( GCC diagnostic pop ))
+#else
+#  define PADDING_GUARD_BEGIN
+#  define PADDING_GUARD_END
+#endif
+
+#endif