endianness issue fix.

This commit is contained in:
rui 2007-12-02 20:46:52 +00:00
parent c8aabd69cf
commit 727b02b65a
2 changed files with 40 additions and 2 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.16 2007/11/17 20:39:03 steven Exp $
# $OpenBSD: Makefile,v 1.17 2007/12/02 20:46:52 rui Exp $
SHARED_ONLY= Yes
COMMENT= determine the malware activity on a network
DISTNAME= nepenthes-20070830
PKGNAME= ${DISTNAME}p1
PKGNAME= ${DISTNAME}p2
CATEGORIES= net
HOMEPAGE= http://nepenthes.mwcollect.org/

View File

@ -0,0 +1,38 @@
$OpenBSD: patch-nepenthes-core_src_DownloadManager_cpp,v 1.1 2007/12/02 20:46:52 rui Exp $
--- nepenthes-core/src/DownloadManager.cpp.orig Thu Aug 30 23:14:37 2007
+++ nepenthes-core/src/DownloadManager.cpp Sun Dec 2 18:20:26 2007
@@ -28,6 +28,7 @@
/* $Id: patch-nepenthes-core_src_DownloadManager_cpp,v 1.1 2007/12/02 20:46:52 rui Exp $ */
#include <string>
+#include <sys/param.h>
#include "DownloadManager.hpp"
#include "DownloadHandler.hpp"
@@ -114,16 +115,16 @@ bool DownloadManager::Exit()
* these cool makros are taken from the clamav mailing list
*
*/
-//#ifndef BIG_ENDIAN
-// #define SWAP_ORDER(x) (x)
-//#else
- #define SWAP_ORDER(x) ( \
- ((x & 0xff) << 24) | \
- ((x & 0xff00) << 8) | \
- ((x & 0xff0000) >> 8 ) | \
- ((x & 0xff000000) >> 24 ))
-//#endif
-
+#if BYTE_ORDER == BIG_ENDIAN
+ #define SWAP_ORDER(x) (x)
+#else
+ #define SWAP_ORDER(x) ( \
+ ((x & 0xff) << 24) | \
+ ((x & 0xff00) << 8) | \
+ ((x & 0xff0000) >> 8 ) | \
+ ((x & 0xff000000) >> 24 ))
+#endif
+
#define PACKADDR(a, b, c, d) SWAP_ORDER((((uint32_t)(a) << 24) | ((b) << 16) | ((c) << 8) | (d)))
#define MAKEMASK(bits) SWAP_ORDER(((uint32_t)(0xffffffff << (32-bits))))