Fixed Windows build errors; native byte swap functions used on Windows; fixed libnetx...
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 2 Dec 2016 14:39:19 +0000 (16:39 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 2 Dec 2016 14:39:19 +0000 (16:39 +0200)
include/nms_common.h
include/nms_util.h
src/agent/core/exec.cpp
src/flow_analyzer/libipfix/libipfix.h
src/libnetxms/crypto.cpp
src/libnetxms/tools.cpp
src/server/core/cert.cpp
src/server/core/datacoll.cpp
tests/test-libnetxms/test-libnetxms.cpp

index 6a59af4..0c1419c 100644 (file)
@@ -51,6 +51,7 @@
 
 #ifndef UNDER_CE
 #define _WITH_ENCRYPTION   1
+#define WITH_OPENSSL       1
 #define WITH_LDAP          1
 #if !defined(WINDOWS_ONLY) && !defined(_CRT_SECURE_NO_DEPRECATE)
 #define _CRT_SECURE_NO_DEPRECATE
@@ -291,6 +292,14 @@ typedef unsigned __int64 uint64_t;
 #define TIME_T_FCAST(x) ((UINT32)(x))
 #endif
 
+#define HAVE_DECL_BSWAP_16 1
+#define HAVE_DECL_BSWAP_32 1
+#define HAVE_DECL_BSWAP_64 1
+
+#define bswap_16  _byteswap_ushort
+#define bswap_32  _byteswap_ulong
+#define bswap_64  _byteswap_uint64
+
 // Socket compatibility
 #define SHUT_RD      0
 #define SHUT_WR      1
index 31a474c..c3c79af 100644 (file)
@@ -89,7 +89,7 @@ inline UINT32 bswap_32(UINT32 val)
 {
    UINT32 result;
    BYTE *sptr = (BYTE *)&val;
-   BYTE *dptr = (BYTE *)&result + 7;
+   BYTE *dptr = (BYTE *)&result + 3;
    for(int i = 0; i < 4; i++, sptr++, dptr--)
       *dptr = *sptr;
    return result;
index c6547fa..e0a9538 100644 (file)
@@ -440,7 +440,7 @@ LONG RunExternal(const TCHAR *pszCmd, const TCHAR *pszArg, StringList *value)
                        if (CreateProcess(NULL, pszCmdLine, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
                        {
                                // Wait for process termination and close all handles
-                               if (WaitForSingleObject(pi.hProcess, g_dwExecTimeout) == WAIT_OBJECT_0)
+                               if (WaitForSingleObject(pi.hProcess, g_execTimeout) == WAIT_OBJECT_0)
                                {
                                        // Rewind temporary file for reading
                                        SetFilePointer(hOutput, 0, NULL, FILE_BEGIN);
index ddfa5c9..099fd40 100644 (file)
@@ -4,6 +4,7 @@
 #include <nms_common.h>
 #include <nms_util.h>
 #include <nms_threads.h>
+#include <nxcrypto.h>
 
 #ifdef _WIN32
 #define hstrerror strerror
index 4266cd6..5f40e05 100644 (file)
@@ -314,7 +314,7 @@ UINT32 LIBNETXMS_EXPORTABLE SetupEncryptionContext(NXCPMessage *msg,
       }
       else
       {
-                       BYTE *pBufPos, ucKeyBuffer[KEY_BUFFER_SIZE];
+                       BYTE ucKeyBuffer[KEY_BUFFER_SIZE];
                        RSA *pServerKey;
 
                        *ppCtx = NXCPEncryptionContext::create(dwCiphers);
index 938dda9..8b2b23e 100644 (file)
@@ -1078,7 +1078,11 @@ retry:
                           SocketPoller p(true);
                           p.add(hSocket);
                                nRet = p.poll(60000);
+#ifdef _WIN32
+                               if (nRet > 0)
+#else
                                if ((nRet > 0) || ((nRet == -1) && (errno == EINTR)))
+#endif
                                        goto retry;
                        }
                        break;
index 890d26d..04985ff 100644 (file)
@@ -21,6 +21,7 @@
 **/
 
 #include "nxcore.h"
+#include <nxcrypto.h>
 
 #ifdef _WITH_ENCRYPTION
 
index 360f53b..ad09f59 100644 (file)
@@ -376,7 +376,7 @@ static void QueueItems(NetObj *object, void *data)
  */
 static THREAD_RESULT THREAD_CALL ItemPoller(void *pArg)
 {
-   UINT32 dwSum, dwWatchdogId, currPos = 0;
+   UINT32 dwSum, currPos = 0;
    UINT32 dwTimingHistory[60 / ITEM_POLLING_INTERVAL];
    INT64 qwStart;
 
@@ -387,7 +387,7 @@ static THREAD_RESULT THREAD_CALL ItemPoller(void *pArg)
    {
       if (SleepAndCheckForShutdown(ITEM_POLLING_INTERVAL))
          break;      // Shutdown has arrived
-      WatchdogNotify(dwWatchdogId);
+      WatchdogNotify(watchdogId);
                DbgPrintf(8, _T("ItemPoller: wakeup"));
 
       qwStart = GetCurrentTimeMs();
index dc83f58..d88fa3d 100644 (file)
@@ -350,16 +350,19 @@ static void TestInetAddress()
    BYTE key[18];
    a.buildHashKey(key);
 #if WORDS_BIGENDIAN
-   AssertTrue(memcmp(key, "\x06\x02\x0A\x03\x01\x5B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 18) == 0);
+   static BYTE keyIPv4[] = { 0x06, AF_INET, 0x0A, 0x03, 0x01, 0x5B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+   AssertTrue(memcmp(key, keyIPv4, 18) == 0);
 #else
-   AssertTrue(memcmp(key, "\x06\x02\x5B\x01\x03\x0A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 18) == 0);
+   static BYTE keyIPv4[] = { 0x06, AF_INET, 0x5B, 0x01, 0x03, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+   AssertTrue(memcmp(key, keyIPv4, 18) == 0);
 #endif
    EndTest();
    
    StartTest(_T("InetAddress - buildHashKey() - IPv6"));
    a = InetAddress::parse("fe80:1234::6e88:14ff:fec4:b8f8");
    a.buildHashKey(key);
-   AssertTrue(memcmp(key, "\x12\x0A\xFE\x80\x12\x34\x00\x00\x00\x00\x6E\x88\x14\xFF\xFE\xC4\xB8\xF8", 18) == 0);
+   static BYTE keyIPv6[] = { 0x12, AF_INET6, 0xFE, 0x80, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x88, 0x14, 0xFF, 0xFE, 0xC4, 0xB8, 0xF8 };
+   AssertTrue(memcmp(key, keyIPv6, 18) == 0);
    EndTest();
 }