From 2109911e3bc39596e73f8c6cd6f10837d7037870 Mon Sep 17 00:00:00 2001 From: "Russ Combs (rucombs)" Date: Wed, 3 Feb 2016 08:39:00 -0500 Subject: [PATCH] Merge pull request #225 in SNORT/snort3 from ~MIALTIZE/snort3:for-russ to master Squashed commit of the following: commit 65ec53744d1f200275a4aed1b021fecfe45edf90 Author: Michael Altizer Date: Tue Feb 2 17:12:23 2016 -0500 extra: Use pkg-config to retrieve Snort includes dir, remove explicit option commit af06110d9e32bab85b443c72ee290005cbc95899 Author: Michael Altizer Date: Tue Feb 2 17:11:00 2016 -0500 snort.pc: Only export CPPFLAGS as Cflags (should be further pruned/controlled) commit d6ecbb16ba40638a120c11c0d0baf11bb85ba257 Author: Michael Altizer Date: Tue Feb 2 11:21:12 2016 -0500 extra: Prefer clang compiler like Snort does. commit 8539fc0f7e4fee80ee4e90b07a0fbd14a1416b3d Author: Michael Altizer Date: Tue Feb 2 11:19:23 2016 -0500 snort.pc: Add Snort install dir to CPPFLAGS includes Note: This is sort of an ugly subversion of pkg-config, but I'm just following suit. commit 6f1795ad3db90b468d3c6ae2d4e7e47c97806e64 Author: Michael Altizer Date: Mon Feb 1 16:00:47 2016 -0500 sfdaq: Conditionally support new-style daq_modify_flow() commit 3ca33d0ad7839e3583e2630a949c94284e15ce68 Author: Michael Altizer Date: Tue Jan 19 13:47:10 2016 -0500 Remove DAQ_GetAddressSpaceID. We don't support LibDAQ versions without address space ID anymore. commit 88707f0f4cfb74ef108c7880a710b0345d8d040f Author: Michael Altizer Date: Mon Jan 4 15:38:02 2016 -0500 autoconf: Prefer clang over gcc for CC to match CXX --- configure.ac | 5 +++-- extra/README | 8 ++++---- extra/configure.ac | 37 +++++++++++++++++++++++-------------- extra/configure_cmake.sh | 7 ------- snort.pc.in | 4 +--- src/flow/flow_control.cc | 2 +- src/packet_io/sfdaq.cc | 11 +++++++++-- src/packet_io/sfdaq.h | 7 +------ src/stream/stream_api.cc | 2 +- 9 files changed, 43 insertions(+), 40 deletions(-) diff --git a/configure.ac b/configure.ac index c6aa7c83b..322f14e20 100644 --- a/configure.ac +++ b/configure.ac @@ -33,8 +33,7 @@ AC_CONFIG_HEADERS([config.h src/framework/api_options.h]) AM_INIT_AUTOMAKE(foreign nostdinc) AM_SILENT_RULES([yes]) -LT_INIT - +AC_PROG_CC([clang gcc]) AC_PROG_CXX([clang++ g++]) AC_PROG_AWK AC_PROG_CC @@ -61,6 +60,8 @@ if test "x$CXX" = "xg++"; then fi fi +LT_INIT + PKG_PROG_PKG_CONFIG #-------------------------------------------------------------------------- diff --git a/extra/README b/extra/README index 679da98a0..97ec5f0d0 100644 --- a/extra/README +++ b/extra/README @@ -58,13 +58,13 @@ Follow these steps: * To build with autotools, simply do the usual from the top level directory: - ./configure --prefix=$my_path --with-snort-includes=$my_path/include/snort + ./configure --prefix=$my_path make -j 8 install -* To build with cmake, do the following: +* To build with cmake and make, run configure_cmake.sh. It will automatically create and populate a new subdirectory named 'build'. - mkdir build && cd build - cmake .. + ./configure_cmake.sh --prefix=$my_path + cd build make -j 8 install Note: diff --git a/extra/configure.ac b/extra/configure.ac index 00e77d824..fe80100c1 100644 --- a/extra/configure.ac +++ b/extra/configure.ac @@ -12,29 +12,21 @@ AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE(foreign) AM_SILENT_RULES([yes]) -LT_INIT - # Checks for programs. -AC_PROG_CXX +AC_PROG_CC([clang gcc]) +AC_PROG_CXX([clang++ g++]) AC_PROG_LIBTOOL +LT_INIT + # Use the same defines Snort used # (absolutely critical to ensure struct definitions match) -CFLAGS=`pkg-config --cflags snort` -CXXFLAGS=`pkg-config --variable=cxxflags snort` -CPPFLAGS=`pkg-config --variable=cppflags snort` +CPPFLAGS="$CPPFLAGS `pkg-config --cflags snort`" -CPPFLAGS+=" -DBUILDING_SO" +CPPFLAGS="$CPPFLAGS -DBUILDING_SO" AX_CXX_COMPILE_STDCXX_11 -AC_ARG_WITH(snort-includes, - AC_HELP_STRING([--with-snort-includes=DIR],[snort include directory]), - [with_snort_includes="$withval"],[with_snort_includes="no"]) - -if test "x$with_snort_includes" != "xno"; then - CPPFLAGS="${CPPFLAGS} -I${with_snort_includes}" -fi #-------------------------------------------------------------------------- # visibility foo @@ -92,3 +84,20 @@ AC_CONFIG_FILES([ \ AC_OUTPUT +AC_MSG_RESULT([ + $PACKAGE $VERSION + ======== + + prefix: ${prefix} + sysconfdir: ${sysconfdir} + libdir: ${libdir} + includedir: ${includedir} + + compiler: ${CC} + compiler++: ${CXX} + cflags: ${CFLAGS} + cxxflags: ${CXXFLAGS} + cppflags: ${CPPFLAGS} + ldflags: ${LDFLAGS} + libs: ${LIBS} +]) diff --git a/extra/configure_cmake.sh b/extra/configure_cmake.sh index 640a8fe34..0cb488e31 100755 --- a/extra/configure_cmake.sh +++ b/extra/configure_cmake.sh @@ -21,7 +21,6 @@ Usage: $0 [OPTION]... [VAR=VALUE]... --prefix= Snort++ installation prefix Optional Packages: - --with-snort-includes=DIR snort include directory --with-daq-includes=DIR DAQ include directory --with-daq-libraries=DIR DAQ library directory --with-luajit-includes=DIR luajit include directory @@ -82,12 +81,6 @@ while [ $# -ne 0 ]; do prefix=$optarg append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg ;; - --with-snort-includes=*) - append_cache_entry SNORT_INCLUDE_DIR PATH $optarg - ;; - --with-snort-executable=*) - append_cache_entry SNORT_EXECUTABLE FILEPATH $optarg - ;; --with-luajit-includes=*) append_cache_entry LUAJIT_INCLUDE_DIR PATH $optarg ;; diff --git a/snort.pc.in b/snort.pc.in index bcb1519bd..02ed931cc 100644 --- a/snort.pc.in +++ b/snort.pc.in @@ -7,13 +7,11 @@ datarootdir=@datarootdir@ datadir=@datadir@ mandir=@infodir@ infodir=@infodir@ -cppflags=@CPPFLAGS@ -cxxflags=@CXXFLAGS@ Name: Snort++ Description: Snort 3.0 Project URL: www.snort.org Version: @VERSION@ Libs: -L${libdir} -lcurl @LDFLAGS@ @LIBS@ -Cflags: @CFLAGS@ +Cflags: @CPPFLAGS@ -I${includedir}/snort diff --git a/src/flow/flow_control.cc b/src/flow/flow_control.cc index a2fd4dd4e..68f2ca146 100644 --- a/src/flow/flow_control.cc +++ b/src/flow/flow_control.cc @@ -286,7 +286,7 @@ void FlowControl::set_key(FlowKey* key, Packet* p) else mplsId = 0; - addressSpaceId = DAQ_GetAddressSpaceID(p->pkth); + addressSpaceId = p->pkth->address_space_id; if ( (p->ptrs.decode_flags & DECODE_FRAG) ) { diff --git a/src/packet_io/sfdaq.cc b/src/packet_io/sfdaq.cc index 160e34b3c..c2b1bdbe9 100644 --- a/src/packet_io/sfdaq.cc +++ b/src/packet_io/sfdaq.cc @@ -590,12 +590,19 @@ const DAQ_Stats_t* DAQ_GetStats(void) //-------------------------------------------------------------------- -int DAQ_ModifyFlow(const void* h, uint32_t id) +int DAQ_ModifyFlowOpaque(const void* h, uint32_t opaque) { const DAQ_PktHdr_t* hdr = (DAQ_PktHdr_t*)h; DAQ_ModFlow_t mod; - mod.opaque = id; +#ifdef DAQ_MODFLOW_TYPE_OPAQUE + mod.type = DAQ_MODFLOW_TYPE_OPAQUE; + mod.length = sizeof(opaque); + mod.value = &opaque; +#else + mod.opaque = opaque; +#endif + return daq_modify_flow(daq_mod, daq_hand, hdr, &mod); } diff --git a/src/packet_io/sfdaq.h b/src/packet_io/sfdaq.h index 7eae8d156..79abcc64c 100644 --- a/src/packet_io/sfdaq.h +++ b/src/packet_io/sfdaq.h @@ -78,12 +78,7 @@ int DAQ_BreakLoop(int error, void* handle = nullptr); void DAQ_Set_MetaCallback(DAQ_Meta_Func_t meta_callback); SO_PUBLIC DAQ_Mode DAQ_GetInterfaceMode(const DAQ_PktHdr_t* h); -int DAQ_ModifyFlow(const void* h, uint32_t id); - -static inline uint16_t DAQ_GetAddressSpaceID(const DAQ_PktHdr_t* h) -{ - return h->address_space_id; -} +int DAQ_ModifyFlowOpaque(const void* h, uint32_t opaque); // returns total stats if no daq else current stats // returns statically allocated stats - don't free diff --git a/src/stream/stream_api.cc b/src/stream/stream_api.cc index 707900551..f2b503570 100644 --- a/src/stream/stream_api.cc +++ b/src/stream/stream_api.cc @@ -122,7 +122,7 @@ void Stream::populate_session_key(Packet* p, FlowKey* key) // if the vlan protocol bit is defined, vlan layer gauranteed to exist (p->proto_bits & PROTO_BIT__VLAN) ? layer::get_vlan_layer(p)->vid() : 0, (p->proto_bits & PROTO_BIT__MPLS) ? p->ptrs.mplsHdr.label : 0, - DAQ_GetAddressSpaceID(p->pkth)); + p->pkth->address_space_id); } FlowKey* Stream::get_session_key(Packet* p) -- 2.47.3