Fixed a problem with byte switching
[umurmur.git] / src / crypt.h
index 250483a57da9e021887294640bcfab926f0971ee..300563e0aa5064f5ec91bacb9db07ddd58f5eb8e 100644 (file)
@@ -1,5 +1,5 @@
-/* Copyright (C) 2009-2013, Martin Johansson <martin@fatbob.nu>
-   Copyright (C) 2005-2013, Thorvald Natvig <thorvald@natvig.com>
+/* Copyright (C) 2009-2014, Martin Johansson <martin@fatbob.nu>
+   Copyright (C) 2005-2014, Thorvald Natvig <thorvald@natvig.com>
 
    All rights reserved.
 
 #ifndef CRYPTSTATE_H_34564356
 #define CRYPTSTATE_H_34564356
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#ifdef NETBSD
+#include <machine/endian.h>
+#if BYTE_ORDER == BIG_ENDIAN
+#define CRYPT_BE
+#endif
+#endif
+
+#ifdef LINUX
+#include <endian.h>
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define CRYPT_BE
+#endif
 #endif
 
+#include "config.h"
+
 #ifdef USE_POLARSSL
 #include <polarssl/havege.h>
 #include <polarssl/aes.h>
@@ -53,12 +65,12 @@ typedef struct CryptState {
        uint8_t encrypt_iv[AES_BLOCK_SIZE];
        uint8_t decrypt_iv[AES_BLOCK_SIZE];
        uint8_t decrypt_history[0x100];
-       
+
        unsigned int uiGood;
        unsigned int uiLate;
        unsigned int uiLost;
        unsigned int uiResync;
-       
+
        unsigned int uiRemoteGood;
        unsigned int uiRemoteLate;
        unsigned int uiRemoteLost;
@@ -72,7 +84,7 @@ typedef struct CryptState {
 #endif
        etimer_t tLastGood;
        etimer_t tLastRequest;
-       bool_t bInit;   
+       bool_t bInit;
 } cryptState_t;
 
 void CryptState_init(cryptState_t *cs);