[See comments to previous commits]
[public/netxms.git] / include / nms_util.h
CommitLineData
e9246d26 1/*
7ac71e60 2** NetXMS - Network Management System
e9246d26
VK
3** Copyright (C) 2003 Victor Kirhenshtein
4**
5** This program is free software; you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation; either version 2 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18**
19** $module: nms_util.h
20**
21**/
22
23#ifndef _nms_util_h_
24#define _nms_util_h_
25
64584976
VK
26#ifdef _WIN32
27#ifdef LIBNETXMS_EXPORTS
28#define LIBNETXMS_EXPORTABLE __declspec(dllexport)
29#else
30#define LIBNETXMS_EXPORTABLE __declspec(dllimport)
31#endif
32#else /* _WIN32 */
33#define LIBNETXMS_EXPORTABLE
34#endif
35
36
e9246d26
VK
37#include <nms_common.h>
38#include <nms_cscp.h>
5fad5c32 39#include <nms_threads.h>
64584976 40#include <time.h>
e9246d26 41
f52be742
VK
42#if HAVE_BYTESWAP_H
43#include <byteswap.h>
44#endif
45
5d63b3c1
VK
46#define INVALID_INDEX 0xFFFFFFFF
47#define CSCP_TEMP_BUF_SIZE 4096
89bfdd9c 48#define MD5_DIGEST_SIZE 16
d0b249a8 49#define SHA1_DIGEST_SIZE 20
5d63b3c1
VK
50
51
52//
66c04cc7
VK
53// Return codes for IcmpPing()
54//
55
56#define ICMP_SUCCESS 0
57#define ICMP_UNREACHEABLE 1
58#define ICMP_TIMEOUT 2
59#define ICMP_RAW_SOCK_FAILED 3
60
61
62//
dcb44c9a
VK
63// Modes for NxInitSharedData
64//
65
66#define MODE_SHM 1
67#define MODE_DB 2
68
69
70//
3046f9a4
VK
71// getopt() prototype if needed
72//
73
74#ifdef _WIN32
75#include <getopt.h>
76#endif
77
78
79//
e9246d26
VK
80// Functions
81//
82
43d92b4c
VK
83
84#if __BYTE_ORDER == __LITTLE_ENDIAN
85#define htonq(x) __bswap_64(x)
86#define ntohq(x) __bswap_64(x)
87#else
88#define htonq(x) (x)
89#define ntohq(x) (x)
90#endif
15929b31 91
e9246d26
VK
92extern "C"
93{
f52be742 94#if defined(_WIN32) || !(HAVE_DECL___BSWAP_64)
64584976
VK
95 QWORD LIBNETXMS_EXPORTABLE __bswap_64(QWORD qwVal);
96#endif
97
98#ifndef _WIN32
99 void LIBNETXMS_EXPORTABLE strupr(char *in);
7e679c4b 100#endif
ab588c84 101
670c7f3d
VK
102 INT64 LIBNETXMS_EXPORTABLE GetCurrentTimeMs(void);
103
64584976
VK
104 int LIBNETXMS_EXPORTABLE BitsInMask(DWORD dwMask);
105 char LIBNETXMS_EXPORTABLE *IpToStr(DWORD dwAddr, char *szBuffer);
a1dc75b0 106
64584976
VK
107 void LIBNETXMS_EXPORTABLE *MemAlloc(DWORD dwSize);
108 void LIBNETXMS_EXPORTABLE *MemReAlloc(void *pBlock, DWORD dwNewSize);
109 void LIBNETXMS_EXPORTABLE MemFree(void *pBlock);
93b18807 110
64584976
VK
111 void LIBNETXMS_EXPORTABLE *nx_memdup(const void *pData, DWORD dwSize);
112 char LIBNETXMS_EXPORTABLE *nx_strdup(const char *pSrc);
31521248 113
64584976
VK
114 void LIBNETXMS_EXPORTABLE StrStrip(char *pszStr);
115 BOOL LIBNETXMS_EXPORTABLE MatchString(const char *pattern, const char *string, BOOL matchCase);
7774d71f 116 char LIBNETXMS_EXPORTABLE *ExtractWord(char *line, char *buffer);
64584976
VK
117
118 DWORD LIBNETXMS_EXPORTABLE CalculateCRC32(const unsigned char *data, DWORD nbytes);
a48063fc
VK
119 void LIBNETXMS_EXPORTABLE CalculateMD5Hash(const unsigned char *data, int nbytes, unsigned char *hash);
120 void LIBNETXMS_EXPORTABLE CalculateSHA1Hash(unsigned char *data, int nbytes, unsigned char *hash);
66c04cc7
VK
121
122 DWORD LIBNETXMS_EXPORTABLE IcmpPing(DWORD dwAddr, int iNumRetries, DWORD dwTimeout, DWORD *pdwRTT);
e9246d26
VK
123}
124
125#endif /* _nms_util_h_ */