added extra memory to maven in nxshell makefile
[public/netxms.git] / include / nxcpapi.h
CommitLineData
9fa031cd 1/*
0d9c1b96 2** NetXMS - Network Management System
9f2ad16c 3** NXCP API
68f384ea 4** Copyright (C) 2003-2010 Victor Kirhenshtein
0d9c1b96
VK
5**
6** This program is free software; you can redistribute it and/or modify
65d2c384
VK
7** it under the terms of the GNU Lesser General Public License as published by
8** the Free Software Foundation; either version 3 of the License, or
0d9c1b96
VK
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
68f384ea 16** You should have received a copy of the GNU Lesser General Public License
0d9c1b96
VK
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19**
9f2ad16c 20** File: nxcpapi.h
0d9c1b96
VK
21**
22**/
23
9f2ad16c
VK
24#ifndef _nxcpapi_h_
25#define _nxcpapi_h_
0d9c1b96 26
9f2ad16c 27#include <nms_util.h>
bf6fb6c3 28#include <nms_threads.h>
9c3bf7f4 29#include <nxcrypto.h>
de4af576 30#include <uuid.h>
8c290af0 31
bb8136f7
VK
32#ifdef _WIN32
33#include <wincrypt.h>
34#endif
35
4af351c7 36/**
b368969c 37 * Temporary buffer structure for RecvNXCPMessage() function
4af351c7 38 */
0d9c1b96
VK
39typedef struct
40{
b368969c
VK
41 UINT32 bufferSize;
42 UINT32 bufferPos;
43a6f3ca 43 char buffer[NXCP_TEMP_BUF_SIZE];
b368969c 44} NXCP_BUFFER;
0d9c1b96
VK
45
46
9f2ad16c
VK
47#ifdef __cplusplus
48
5c44534b
VK
49struct MessageField;
50
4af351c7
VK
51/**
52 * Parsed NXCP message
53 */
b368969c 54class LIBNETXMS_EXPORTABLE NXCPMessage
0d9c1b96
VK
55{
56private:
b368969c
VK
57 UINT16 m_code;
58 UINT16 m_flags;
5c44534b 59 UINT32 m_id;
6be0a20b
VK
60 MessageField *m_fields; // Message fields
61 int m_version; // Protocol version
62 BYTE *m_data; // binary data
63 size_t m_dataSize; // binary data size
0d9c1b96 64
712b2760 65 void *set(UINT32 fieldId, BYTE type, const void *value, bool isSigned = false, size_t size = 0);
ca0a165b
VK
66 void *get(UINT32 fieldId, BYTE requiredType, BYTE *fieldType = NULL) const;
67 NXCP_MESSAGE_FIELD *find(UINT32 fieldId) const;
0d9c1b96
VK
68
69public:
b368969c
VK
70 NXCPMessage(int version = NXCP_VERSION);
71 NXCPMessage(NXCPMessage *msg);
72 NXCPMessage(NXCP_MESSAGE *rawMag, int version = NXCP_VERSION);
73 ~NXCPMessage();
0d9c1b96 74
9674aefa 75 NXCP_MESSAGE *createMessage(bool allowCompression = false) const;
0d9c1b96 76
ca0a165b 77 UINT16 getCode() const { return m_code; }
b368969c 78 void setCode(UINT16 code) { m_code = code; }
0d9c1b96 79
ca0a165b 80 UINT32 getId() const { return m_id; }
b368969c 81 void setId(UINT32 id) { m_id = id; }
0d9c1b96 82
4970ef34
VK
83 int getProtocolVersion() const { return m_version; }
84 void setProtocolVersion(int version) { m_version = version; }
85
ca0a165b
VK
86 bool isEndOfFile() const { return (m_flags & MF_END_OF_FILE) ? true : false; }
87 bool isEndOfSequence() const { return (m_flags & MF_END_OF_SEQUENCE) ? true : false; }
88 bool isReverseOrder() const { return (m_flags & MF_REVERSE_ORDER) ? true : false; }
89 bool isBinary() const { return (m_flags & MF_BINARY) ? true : false; }
90 bool isControl() const { return (m_flags & MF_CONTROL) ? true : false; }
3a1356ab 91 bool isCompressedStream() const { return ((m_flags & (MF_COMPRESSED | MF_STREAM)) == (MF_COMPRESSED | MF_STREAM)) ? true : false; }
6be0a20b 92
ca0a165b
VK
93 const BYTE *getBinaryData() const { return m_data; }
94 size_t getBinaryDataSize() const { return m_dataSize; }
4af351c7 95
ca0a165b
VK
96 bool isFieldExist(UINT32 fieldId) const { return find(fieldId) != NULL; }
97 int getFieldType(UINT32 fieldId) const;
4101571e 98
712b2760
VK
99 void setField(UINT32 fieldId, INT16 value) { set(fieldId, NXCP_DT_INT16, &value, true); }
100 void setField(UINT32 fieldId, UINT16 value) { set(fieldId, NXCP_DT_INT16, &value, false); }
101 void setField(UINT32 fieldId, INT32 value) { set(fieldId, NXCP_DT_INT32, &value, true); }
102 void setField(UINT32 fieldId, UINT32 value) { set(fieldId, NXCP_DT_INT32, &value, false); }
103 void setField(UINT32 fieldId, INT64 value) { set(fieldId, NXCP_DT_INT64, &value, true); }
104 void setField(UINT32 fieldId, UINT64 value) { set(fieldId, NXCP_DT_INT64, &value, false); }
b368969c 105 void setField(UINT32 fieldId, double value) { set(fieldId, NXCP_DT_FLOAT, &value); }
19a2cd39 106 void setField(UINT32 fieldId, bool value) { INT16 v = value ? 1 : 0; set(fieldId, NXCP_DT_INT16, &v, true); }
b368969c 107 void setField(UINT32 fieldId, const TCHAR *value) { if (value != NULL) set(fieldId, NXCP_DT_STRING, value); }
712b2760 108 void setField(UINT32 fieldId, const TCHAR *value, size_t maxLen) { if (value != NULL) set(fieldId, NXCP_DT_STRING, value, false, maxLen); }
5f573844 109 void setField(UINT32 fieldId, const BYTE *value, size_t size) { set(fieldId, NXCP_DT_BINARY, value, false, size); }
de4af576
VK
110 void setField(UINT32 fieldId, const InetAddress& value) { set(fieldId, NXCP_DT_INETADDR, &value); }
111 void setField(UINT32 fieldId, const uuid& value) { set(fieldId, NXCP_DT_BINARY, value.getValue(), false, UUID_LENGTH); }
35f836fe 112#ifdef UNICODE
b368969c 113 void setFieldFromMBString(UINT32 fieldId, const char *value);
35f836fe 114#else
b368969c 115 void setFieldFromMBString(UINT32 fieldId, const char *value) { set(fieldId, NXCP_DT_STRING, value); }
35f836fe 116#endif
b368969c 117 void setFieldFromTime(UINT32 fieldId, time_t value) { UINT64 t = (UINT64)value; set(fieldId, NXCP_DT_INT64, &t); }
14149881 118 void setFieldFromInt32Array(UINT32 fieldId, size_t numElements, const UINT32 *elements);
e30c2442 119 void setFieldFromInt32Array(UINT32 fieldId, const IntegerArray<UINT32> *data);
8f238fd7 120 bool setFieldFromFile(UINT32 fieldId, const TCHAR *pszFileName);
967893bb 121
ca0a165b
VK
122 INT16 getFieldAsInt16(UINT32 fieldId) const;
123 UINT16 getFieldAsUInt16(UINT32 fieldId) const;
124 INT32 getFieldAsInt32(UINT32 fieldId) const;
125 UINT32 getFieldAsUInt32(UINT32 fieldId) const;
126 INT64 getFieldAsInt64(UINT32 fieldId) const;
127 UINT64 getFieldAsUInt64(UINT32 fieldId) const;
128 double getFieldAsDouble(UINT32 fieldId) const;
129 bool getFieldAsBoolean(UINT32 fieldId) const;
130 time_t getFieldAsTime(UINT32 fieldId) const;
131 UINT32 getFieldAsInt32Array(UINT32 fieldId, UINT32 numElements, UINT32 *buffer) const;
132 UINT32 getFieldAsInt32Array(UINT32 fieldId, IntegerArray<UINT32> *data) const;
133 const BYTE *getBinaryFieldPtr(UINT32 fieldId, size_t *size) const;
134 TCHAR *getFieldAsString(UINT32 fieldId, TCHAR *buffer = NULL, size_t bufferSize = 0) const;
135 char *getFieldAsMBString(UINT32 fieldId, char *buffer = NULL, size_t bufferSize = 0) const;
136 char *getFieldAsUtf8String(UINT32 fieldId, char *buffer = NULL, size_t bufferSize = 0) const;
137 UINT32 getFieldAsBinary(UINT32 fieldId, BYTE *buffer, size_t bufferSize) const;
138 InetAddress getFieldAsInetAddress(UINT32 fieldId) const;
139 uuid getFieldAsGUID(UINT32 fieldId) const;
4101571e 140
b368969c 141 void deleteAllFields();
e44ac467 142
5c44534b
VK
143 void disableEncryption() { m_flags |= MF_DONT_ENCRYPT; }
144 void setEndOfSequence() { m_flags |= MF_END_OF_SEQUENCE; }
145 void setReverseOrderFlag() { m_flags |= MF_REVERSE_ORDER; }
934f53da 146
ca0a165b 147 static String dump(const NXCP_MESSAGE *msg, int version);
0d9c1b96
VK
148};
149
4af351c7
VK
150/**
151 * Message waiting queue element structure
152 */
deaa4491
VK
153typedef struct
154{
b368969c 155 void *msg; // Pointer to message, either to NXCPMessage object or raw message
14149881 156 UINT64 sequence; // Sequence number
f128c07c
VK
157 UINT32 id; // Message ID
158 UINT32 ttl; // Message time-to-live in milliseconds
159 UINT16 code; // Message code
160 UINT16 isBinary; // 1 for binary (raw) messages
deaa4491
VK
161} WAIT_QUEUE_ELEMENT;
162
4af351c7 163/**
f128c07c
VK
164 * Max number of waiting threads in message queue
165 */
166#define MAX_MSGQUEUE_WAITERS 32
167
168/**
4af351c7
VK
169 * Message waiting queue class
170 */
9f2ad16c 171class LIBNETXMS_EXPORTABLE MsgWaitQueue
deaa4491 172{
deaa4491 173private:
ef8a3c32 174#if defined(_WIN32)
f128c07c
VK
175 CRITICAL_SECTION m_mutex;
176 HANDLE m_wakeupEvents[MAX_MSGQUEUE_WAITERS];
177 BYTE m_waiters[MAX_MSGQUEUE_WAITERS];
ef8a3c32
VK
178#elif defined(_USE_GNU_PTH)
179 pth_mutex_t m_mutex;
180 pth_cond_t m_wakeupCondition;
f128c07c
VK
181#else
182 pthread_mutex_t m_mutex;
183 pthread_cond_t m_wakeupCondition;
184#endif
f128c07c
VK
185 UINT32 m_holdTime;
186 int m_size;
187 int m_allocated;
188 WAIT_QUEUE_ELEMENT *m_elements;
14149881 189 UINT64 m_sequence;
deaa4491 190
f128c07c
VK
191 void *waitForMessageInternal(UINT16 isBinary, UINT16 code, UINT32 id, UINT32 timeout);
192
193 void lock()
194 {
195#ifdef _WIN32
196 EnterCriticalSection(&m_mutex);
ef8a3c32
VK
197#elif defined(_USE_GNU_PTH)
198 pth_mutex_acquire(&m_mutex, FALSE, NULL);
f128c07c
VK
199#else
200 pthread_mutex_lock(&m_mutex);
201#endif
202 }
203
204 void unlock()
205 {
206#ifdef _WIN32
207 LeaveCriticalSection(&m_mutex);
ef8a3c32
VK
208#elif defined(_USE_GNU_PTH)
209 pth_mutex_release(&m_mutex);
f128c07c
VK
210#else
211 pthread_mutex_unlock(&m_mutex);
212#endif
213 }
cc022855 214
d87ddcc2
VK
215 void housekeeperRun();
216
c73c3ba9 217 static Mutex m_housekeeperLock;
669fcb92 218 static HashMap<UINT64, MsgWaitQueue> *m_activeQueues;
c73c3ba9 219 static Condition m_shutdownCondition;
d87ddcc2
VK
220 static THREAD m_housekeeperThread;
221 static EnumerationCallbackResult houseKeeperCallback(const void *key, const void *object, void *arg);
222 static THREAD_RESULT THREAD_CALL housekeeperThread(void *);
223 static EnumerationCallbackResult diagInfoCallback(const void *key, const void *object, void *arg);
deaa4491
VK
224
225public:
226 MsgWaitQueue();
227 ~MsgWaitQueue();
228
b368969c
VK
229 void put(NXCPMessage *pMsg);
230 void put(NXCP_MESSAGE *pMsg);
231 NXCPMessage *waitForMessage(WORD wCode, UINT32 dwId, UINT32 dwTimeOut)
deaa4491 232 {
b368969c 233 return (NXCPMessage *)waitForMessageInternal(0, wCode, dwId, dwTimeOut);
deaa4491 234 }
b368969c 235 NXCP_MESSAGE *waitForRawMessage(WORD wCode, UINT32 dwId, UINT32 dwTimeOut)
deaa4491 236 {
b368969c 237 return (NXCP_MESSAGE *)waitForMessageInternal(1, wCode, dwId, dwTimeOut);
deaa4491 238 }
cc022855 239
c17f6cbc 240 void clear();
f128c07c 241 void setHoldTime(UINT32 holdTime) { m_holdTime = holdTime; }
d87ddcc2
VK
242
243 static void shutdown();
244 static String getDiagInfo();
deaa4491
VK
245};
246
b549a0f8
VK
247/**
248 * NXCP encryption context
249 */
98abc9f1
VK
250class LIBNETXMS_EXPORTABLE NXCPEncryptionContext : public RefCountObject
251{
252private:
253 int m_cipher;
254 BYTE *m_sessionKey;
255 int m_keyLength;
256 BYTE m_iv[EVP_MAX_IV_LENGTH];
e4e091f0 257#ifdef _WITH_ENCRYPTION
9c3bf7f4
VK
258 MUTEX m_encryptorLock;
259#if WITH_OPENSSL
e6336a90
VK
260 EVP_CIPHER_CTX m_encryptor;
261 EVP_CIPHER_CTX m_decryptor;
9c3bf7f4
VK
262#elif WITH_COMMONCRYPTO
263 CCCryptorRef m_encryptor;
264 CCCryptorRef m_decryptor;
265#endif
e4e091f0 266#endif
98abc9f1
VK
267
268 NXCPEncryptionContext();
e6336a90 269 bool initCipher(int cipher);
98abc9f1
VK
270
271public:
b368969c 272 static NXCPEncryptionContext *create(NXCPMessage *msg, RSA *privateKey);
967893bb 273 static NXCPEncryptionContext *create(UINT32 ciphers);
98abc9f1
VK
274
275 virtual ~NXCPEncryptionContext();
276
b368969c 277 NXCP_ENCRYPTED_MESSAGE *encryptMessage(NXCP_MESSAGE *msg);
6be0a20b 278 bool decryptMessage(NXCP_ENCRYPTED_MESSAGE *msg, BYTE *decryptionBuffer);
e6336a90 279
98abc9f1
VK
280 int getCipher() { return m_cipher; }
281 BYTE *getSessionKey() { return m_sessionKey; }
282 int getKeyLength() { return m_keyLength; }
283 BYTE *getIV() { return m_iv; }
284};
285
6be0a20b
VK
286/**
287 * Message receiver result codes
288 */
289enum MessageReceiverResult
290{
291 MSGRECV_SUCCESS = 0,
292 MSGRECV_CLOSED = 1,
293 MSGRECV_TIMEOUT = 2,
294 MSGRECV_COMM_FAILURE = 3,
1bb62997
VK
295 MSGRECV_DECRYPTION_FAILURE = 4,
296 MSGRECV_PROTOCOL_ERROR = 5
6be0a20b
VK
297};
298
299/**
300 * Message receiver - abstract base class
301 */
302class LIBNETXMS_EXPORTABLE AbstractMessageReceiver
303{
304private:
305 BYTE *m_buffer;
306 BYTE *m_decryptionBuffer;
307 NXCPEncryptionContext *m_encryptionContext;
308 size_t m_initialSize;
309 size_t m_size;
310 size_t m_maxSize;
311 size_t m_dataSize;
312 size_t m_bytesToSkip;
313
1bb62997 314 NXCPMessage *getMessageFromBuffer(bool *protocolError);
6be0a20b
VK
315
316protected:
317 virtual int readBytes(BYTE *buffer, size_t size, UINT32 timeout) = 0;
318
319public:
320 AbstractMessageReceiver(size_t initialSize, size_t maxSize);
321 virtual ~AbstractMessageReceiver();
322
323 void setEncryptionContext(NXCPEncryptionContext *ctx) { m_encryptionContext = ctx; }
324
b368969c
VK
325 NXCPMessage *readMessage(UINT32 timeout, MessageReceiverResult *result);
326 NXCP_MESSAGE *getRawMessageBuffer() { return (NXCP_MESSAGE *)m_buffer; }
327
328 static const TCHAR *resultToText(MessageReceiverResult result);
6be0a20b
VK
329};
330
331/**
332 * Message receiver - socket implementation
333 */
334class LIBNETXMS_EXPORTABLE SocketMessageReceiver : public AbstractMessageReceiver
335{
336private:
337 SOCKET m_socket;
338
339protected:
340 virtual int readBytes(BYTE *buffer, size_t size, UINT32 timeout);
341
342public:
343 SocketMessageReceiver(SOCKET socket, size_t initialSize, size_t maxSize);
344 virtual ~SocketMessageReceiver();
345};
346
347/**
348 * Message receiver - UNIX socket/named pipe implementation
349 */
350class LIBNETXMS_EXPORTABLE PipeMessageReceiver : public AbstractMessageReceiver
351{
352private:
353 HPIPE m_pipe;
354#ifdef _WIN32
355 HANDLE m_readEvent;
356#endif
357
358protected:
359 virtual int readBytes(BYTE *buffer, size_t size, UINT32 timeout);
360
361public:
362 PipeMessageReceiver(HPIPE pipe, size_t initialSize, size_t maxSize);
363 virtual ~PipeMessageReceiver();
364};
365
503da871 366/**
d3a20572 367 * NXCP stresam compression methods
503da871 368 */
d3a20572 369enum NXCPStreamCompressionMethod
503da871 370{
d3a20572 371 NXCP_STREAM_COMPRESSION_NONE = 0,
90ed558d
VK
372 NXCP_STREAM_COMPRESSION_LZ4 = 1,
373 NXCP_STREAM_COMPRESSION_DEFLATE = 2
503da871
VK
374};
375
376/**
377 * Abstract stream compressor
378 */
379class LIBNETXMS_EXPORTABLE StreamCompressor
380{
381public:
9757ca46
VK
382 virtual ~StreamCompressor();
383
503da871
VK
384 virtual size_t compress(const BYTE *in, size_t inSize, BYTE *out, size_t maxOutSize) = 0;
385 virtual size_t decompress(const BYTE *in, size_t inSize, const BYTE **out) = 0;
386 virtual size_t compressBufferSize(size_t dataSize) = 0;
387
d3a20572 388 static StreamCompressor *create(NXCPStreamCompressionMethod method, bool compress, size_t maxBlockSize);
503da871
VK
389};
390
391/**
392 * Dummy stream compressor
393 */
394class LIBNETXMS_EXPORTABLE DummyStreamCompressor : public StreamCompressor
395{
396public:
9757ca46
VK
397 virtual ~DummyStreamCompressor();
398
503da871
VK
399 virtual size_t compress(const BYTE *in, size_t inSize, BYTE *out, size_t maxOutSize);
400 virtual size_t decompress(const BYTE *in, size_t inSize, const BYTE **out);
401 virtual size_t compressBufferSize(size_t dataSize);
402};
403
404struct __LZ4_stream_t;
405struct __LZ4_streamDecode_t;
406
407/**
408 * LZ4 stream compressor
409 */
410class LIBNETXMS_EXPORTABLE LZ4StreamCompressor : public StreamCompressor
411{
412private:
413 union
414 {
415 __LZ4_stream_t *encoder;
416 __LZ4_streamDecode_t *decoder;
417 } m_stream;
418 char *m_buffer;
419 size_t m_maxBlockSize;
420 size_t m_bufferSize;
421 size_t m_bufferPos;
422 bool m_compress;
423
424public:
425 LZ4StreamCompressor(bool compress, size_t maxBlockSize);
426 virtual ~LZ4StreamCompressor();
427
428 virtual size_t compress(const BYTE *in, size_t inSize, BYTE *out, size_t maxOutSize);
429 virtual size_t decompress(const BYTE *in, size_t inSize, const BYTE **out);
430 virtual size_t compressBufferSize(size_t dataSize);
431};
432
90ed558d
VK
433struct z_stream_s;
434
435/**
436 * Deflate stream compressor
437 */
438class LIBNETXMS_EXPORTABLE DeflateStreamCompressor : public StreamCompressor
439{
440private:
441 z_stream_s *m_stream;
442 BYTE *m_buffer;
443 size_t m_bufferSize;
444 bool m_compress;
445
446public:
447 DeflateStreamCompressor(bool compress, size_t maxBlockSize);
448 virtual ~DeflateStreamCompressor();
449
450 virtual size_t compress(const BYTE *in, size_t inSize, BYTE *out, size_t maxOutSize);
451 virtual size_t decompress(const BYTE *in, size_t inSize, const BYTE **out);
452 virtual size_t compressBufferSize(size_t dataSize);
453};
454
208d7427
VK
455#if 0
456/**
457 * NXCP message consumer interface
458 */
459class LIBNETXMS_EXPORTABLE MessageConsumer
460{
461public:
462 virtual SOCKET getSocket() = 0;
463 virtual void processMessage(NXCPMessage *msg) = 0;
464};
465
466/**
467 * Socket receiver - manages receiving NXCP messages from multiple sockets
468 */
469class LIBNETXMS_EXPORTABLE SocketReceiver
470{
471private:
472 THREAD m_thread;
473 HashMap<SOCKET, MessageConsumer> *m_consumers;
474
475 static int m_maxSocketsPerThread;
476 static ObjectArray<SocketReceiver> *m_receivers;
477
478public:
479 static void start();
480 static void shutdown();
481
482 static void addConsumer(MessageConsumer *mc);
483 static void removeConsumer(MessageConsumer *mc);
484
485 static String getDiagInfo();
486};
487#endif
488
9f2ad16c
VK
489#else /* __cplusplus */
490
b368969c 491typedef void NXCPMessage;
98abc9f1 492typedef void NXCPEncryptionContext;
9f2ad16c
VK
493
494#endif
495
da9ac8fc
VK
496typedef bool (*NXCPMessageNameResolver)(UINT16 code, TCHAR *buffer);
497
deaa4491
VK
498
499//
0d9c1b96
VK
500// Functions
501//
502
503#ifdef __cplusplus
0d9c1b96 504
b368969c
VK
505int LIBNETXMS_EXPORTABLE RecvNXCPMessage(SOCKET hSocket, NXCP_MESSAGE *pMsg,
506 NXCP_BUFFER *pBuffer, UINT32 dwMaxMsgSize,
98abc9f1 507 NXCPEncryptionContext **ppCtx,
967893bb 508 BYTE *pDecryptionBuffer, UINT32 dwTimeout);
b368969c
VK
509int LIBNETXMS_EXPORTABLE RecvNXCPMessageEx(SOCKET hSocket, NXCP_MESSAGE **msgBuffer,
510 NXCP_BUFFER *nxcpBuffer, UINT32 *bufferSize,
cc022855 511 NXCPEncryptionContext **ppCtx,
967893bb
VK
512 BYTE **decryptionBuffer, UINT32 dwTimeout,
513 UINT32 maxMsgSize);
d3a20572
VK
514NXCP_MESSAGE LIBNETXMS_EXPORTABLE *CreateRawNXCPMessage(UINT16 code, UINT32 id, UINT16 flags,
515 const void *data, size_t dataSize,
516 NXCP_MESSAGE *buffer, bool allowCompression);
967893bb 517BOOL LIBNETXMS_EXPORTABLE SendFileOverNXCP(SOCKET hSocket, UINT32 dwId, const TCHAR *pszFile,
cc022855 518 NXCPEncryptionContext *pCtx, long offset,
7b8b337e 519 void (* progressCallback)(INT64, void *), void *cbArg,
d3a20572 520 MUTEX mutex, NXCPStreamCompressionMethod compressionMethod = NXCP_STREAM_COMPRESSION_NONE);
7b8b337e 521BOOL LIBNETXMS_EXPORTABLE NXCPGetPeerProtocolVersion(SOCKET hSocket, int *pnVersion, MUTEX mutex);
cc022855 522
da9ac8fc
VK
523TCHAR LIBNETXMS_EXPORTABLE *NXCPMessageCodeName(UINT16 wCode, TCHAR *buffer);
524void LIBNETXMS_EXPORTABLE NXCPRegisterMessageNameResolver(NXCPMessageNameResolver r);
525void LIBNETXMS_EXPORTABLE NXCPUnregisterMessageNameResolver(NXCPMessageNameResolver r);
526
2df047f4 527bool LIBNETXMS_EXPORTABLE InitCryptoLib(UINT32 dwEnabledCiphers);
e5390fb5
VK
528UINT32 LIBNETXMS_EXPORTABLE NXCPGetSupportedCiphers();
529String LIBNETXMS_EXPORTABLE NXCPGetSupportedCiphersAsText();
b368969c 530NXCP_ENCRYPTED_MESSAGE LIBNETXMS_EXPORTABLE *NXCPEncryptMessage(NXCPEncryptionContext *pCtx, NXCP_MESSAGE *pMsg);
bf6fb6c3 531bool LIBNETXMS_EXPORTABLE NXCPDecryptMessage(NXCPEncryptionContext *pCtx,
6be0a20b 532 NXCP_ENCRYPTED_MESSAGE *pMsg,
e44ac467 533 BYTE *pDecryptionBuffer);
b368969c 534UINT32 LIBNETXMS_EXPORTABLE SetupEncryptionContext(NXCPMessage *pMsg,
98abc9f1 535 NXCPEncryptionContext **ppCtx,
b368969c 536 NXCPMessage **ppResponse,
4bd3d6c5 537 RSA *pPrivateKey, int nNXCPVersion);
b368969c 538void LIBNETXMS_EXPORTABLE PrepareKeyRequestMsg(NXCPMessage *pMsg, RSA *pServerKey, bool useX509Format);
3aa0061c 539RSA LIBNETXMS_EXPORTABLE *LoadRSAKeys(const TCHAR *pszKeyFile);
15cf5acc 540
bb8136f7 541#ifdef _WIN32
967893bb 542BOOL LIBNETXMS_EXPORTABLE SignMessageWithCAPI(BYTE *pMsg, UINT32 dwMsgLen, const CERT_CONTEXT *pCert,
b368969c 543 BYTE *pBuffer, size_t bufferSize, UINT32 *pdwSigLen);
bb8136f7
VK
544#endif
545
0d9c1b96
VK
546#endif
547
9f2ad16c 548#endif /* _nxcpapi_h_ */