#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;
/* 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
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.
*/
#include "hash/sfxhash.h"
#include "sfip/sf_ip.h"
+#include "utils/cpp_macros.h"
#include "file_config.h"
{
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;
uint32_t padding;
uint64_t file_sig;
};
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
struct FileNode
{
#include "hash/sfxhash.h"
#include "sfip/sf_ip.h"
+#include "utils/cpp_macros.h"
#include "file_config.h"
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;
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*);
#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()
#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*);
#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
// 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.
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
// Implements rate_filter feature for snort
-#include "main/policy.h"
#include "actions/actions.h"
+#include "main/policy.h"
struct SfIp;
#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
#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
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;
SfIp ip;
uint16_t padding;
} THD_IP_GNODE_KEY;
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
/*!
THD_NODE
#include "catch/catch.hpp"
#include "catch/unit_test.h"
+#include "hash/sfxhash.h"
#include "parser/parse_ip.h"
#include "sfip/sf_ip.h"
*/
#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;
#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
// 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 */
const SfIp *dstIP, uint16_t dstPort,
uint32_t mplsId, bool order = true);
};
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
#endif
#include "log/messages.h"
#include "sfip/sf_ip.h"
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
struct HostPortKey
{
HostPortKey()
IpProtocol proto;
char padding;
};
-#pragma GCC diagnostic pop
+PADDING_GUARD_END
THREAD_LOCAL std::map<HostPortKey, HostPortVal>* host_port_cache = nullptr;
//#define DEBUG_SERVICE_STATE 1
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpadded"
+PADDING_GUARD_BEGIN
class AppIdServiceStateKey
{
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;
#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
{
#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"
#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"
#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"
set( UTIL_INCLUDES
bitop.h
+ cpp_macros.h
dnet_header.h
kmap.h
safec.h
x_include_HEADERS = \
bitop.h \
+cpp_macros.h \
dnet_header.h \
kmap.h \
safec.h \
--- /dev/null
+#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