]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1097 in SNORT/snort3 from bsd_endian to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Wed, 24 Jan 2018 21:12:05 +0000 (16:12 -0500)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Wed, 24 Jan 2018 21:12:05 +0000 (16:12 -0500)
Squashed commit of the following:

commit 47862dd9599f468e6d4fd0294ee2d1fdc653ff43
Author: Carter Waxman <cwaxman@cisco.com>
Date:   Wed Jan 24 09:02:31 2018 -0500

    (squash) fixed header order

commit fcc6f9a9de8e3b1d95905eed50df36206cac04aa
Author: Carter Waxman <cwaxman@cisco.com>
Date:   Tue Jan 23 12:02:20 2018 -0500

    utils, flatbuffers: Added a uniform interface for 64-bit endian swaps

src/network_inspectors/perf_monitor/fbs_formatter.cc
src/utils/CMakeLists.txt
src/utils/Makefile.am
src/utils/endian.h [new file with mode: 0644]
tools/flatbuffers/fbstreamer.cc

index 7be87c9e9a3a1cd05c365188f62908fdc75de02c..75dd7a41b9f6ad5a094a080faba9c9ffbfa239bd 100644 (file)
 
 #include "fbs_formatter.h"
 
-#include <flatbuffers/idl.h>
-#include <flatbuffers/reflection.h>
 #include <queue>
 
-// To simplify builds between OS X and Linux
-#ifndef __APPLE__
-#include <byteswap.h>
-#include <netinet/in.h>
+#include <flatbuffers/idl.h>
+#include <flatbuffers/reflection.h>
 
-#define htonll(a) ( 1 == ntohl(1) ? (a) : bswap_64(a) )
-#endif
+#include "utils/endian.h"
 
 #ifdef UNIT_TEST
 #include <cstdio>
index 2563d202b2ab5f6420f40bb553a4ef71f9dc310c..bfdabaa17fc7c8b3b4d37d63d98dca8337ec9cc4 100644 (file)
@@ -2,6 +2,7 @@
 set( UTIL_INCLUDES
     bitop.h
     cpp_macros.h
+    endian.h
     kmap.h
     safec.h
     segment_mem.h
index 9982bdf40527c7c349c024114361a99247c2c4cd..5aaf81283a4edfa3099f81065440bfbfc78e10a5 100644 (file)
@@ -6,6 +6,7 @@ x_includedir = $(pkgincludedir)/utils
 x_include_HEADERS = \
 bitop.h \
 cpp_macros.h \
+endian.h \
 kmap.h  \
 safec.h \
 segment_mem.h \
diff --git a/src/utils/endian.h b/src/utils/endian.h
new file mode 100644 (file)
index 0000000..371ae93
--- /dev/null
@@ -0,0 +1,43 @@
+//--------------------------------------------------------------------------
+// Copyright (C) 2018-2018 Cisco and/or its affiliates. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License Version 2 as published
+// by the Free Software Foundation.  You may not use, modify or distribute
+// this program under any other version of the GNU General Public License.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//--------------------------------------------------------------------------
+
+// endian.h author Carter Waxman <cwaxman@cisco.com>
+
+// Different POSIX systems handle 64-bit endian swaps in different ways. This
+// header creates a standard interface to use throughout Snort, htonll(value).
+
+#ifndef SNORT_ENDIAN_H
+#define SNORT_ENDIAN_H
+
+# include <netinet/in.h>
+
+#ifdef __FreeBSD__
+# include <sys/endian.h>
+# define bswap_64(a) bswap64(a)
+#endif
+
+#ifdef __linux__
+# include <byteswap.h>
+#endif
+
+#ifndef __APPLE__
+# define htonll(a) ( 1 == htonl(1) ? (a) : bswap_64(a) )
+# define ntohll(a) ( 1 == ntohl(1) ? (a) : bswap_64(a) )
+#endif
+
+#endif
index 1f261ff4371412ad24cb5bd0675f490b74bbac78..1b5679facc3e5aa3b3578609b19d31bd547384bd 100644 (file)
 #include <flatbuffers/idl.h>
 #include <flatbuffers/reflection.h>
 
-// To simplify builds between OS X and Linux
-#ifndef __APPLE__
-#include <byteswap.h>
-#include <netinet/in.h>
-
-#define ntohll(a) ( 1 == ntohl(1) ? (a) : bswap_64(a) )
-#endif
+#include "src/utils/endian.h"
 
 #define OPT_INFILE     0x1
 #define OPT_BEFORE     0x2