Changelog update
[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
ca0a165b
VK
83 bool isEndOfFile() const { return (m_flags & MF_END_OF_FILE) ? true : false; }
84 bool isEndOfSequence() const { return (m_flags & MF_END_OF_SEQUENCE) ? true : false; }
85 bool isReverseOrder() const { return (m_flags & MF_REVERSE_ORDER) ? true : false; }
86 bool isBinary() const { return (m_flags & MF_BINARY) ? true : false; }
87 bool isControl() const { return (m_flags & MF_CONTROL) ? true : false; }
88 bool isCompressed() const { return (m_flags & MF_COMPRESSED) ? true : false; }
6be0a20b 89
ca0a165b
VK
90 const BYTE *getBinaryData() const { return m_data; }
91 size_t getBinaryDataSize() const { return m_dataSize; }
4af351c7 92
ca0a165b
VK
93 bool isFieldExist(UINT32 fieldId) const { return find(fieldId) != NULL; }
94 int getFieldType(UINT32 fieldId) const;
4101571e 95
712b2760
VK
96 void setField(UINT32 fieldId, INT16 value) { set(fieldId, NXCP_DT_INT16, &value, true); }
97 void setField(UINT32 fieldId, UINT16 value) { set(fieldId, NXCP_DT_INT16, &value, false); }
98 void setField(UINT32 fieldId, INT32 value) { set(fieldId, NXCP_DT_INT32, &value, true); }
99 void setField(UINT32 fieldId, UINT32 value) { set(fieldId, NXCP_DT_INT32, &value, false); }
100 void setField(UINT32 fieldId, INT64 value) { set(fieldId, NXCP_DT_INT64, &value, true); }
101 void setField(UINT32 fieldId, UINT64 value) { set(fieldId, NXCP_DT_INT64, &value, false); }
b368969c 102 void setField(UINT32 fieldId, double value) { set(fieldId, NXCP_DT_FLOAT, &value); }
19a2cd39 103 void setField(UINT32 fieldId, bool value) { INT16 v = value ? 1 : 0; set(fieldId, NXCP_DT_INT16, &v, true); }
b368969c 104 void setField(UINT32 fieldId, const TCHAR *value) { if (value != NULL) set(fieldId, NXCP_DT_STRING, value); }
712b2760 105 void setField(UINT32 fieldId, const TCHAR *value, size_t maxLen) { if (value != NULL) set(fieldId, NXCP_DT_STRING, value, false, maxLen); }
5f573844 106 void setField(UINT32 fieldId, const BYTE *value, size_t size) { set(fieldId, NXCP_DT_BINARY, value, false, size); }
de4af576
VK
107 void setField(UINT32 fieldId, const InetAddress& value) { set(fieldId, NXCP_DT_INETADDR, &value); }
108 void setField(UINT32 fieldId, const uuid& value) { set(fieldId, NXCP_DT_BINARY, value.getValue(), false, UUID_LENGTH); }
35f836fe 109#ifdef UNICODE
b368969c 110 void setFieldFromMBString(UINT32 fieldId, const char *value);
35f836fe 111#else
b368969c 112 void setFieldFromMBString(UINT32 fieldId, const char *value) { set(fieldId, NXCP_DT_STRING, value); }
35f836fe 113#endif
b368969c 114 void setFieldFromTime(UINT32 fieldId, time_t value) { UINT64 t = (UINT64)value; set(fieldId, NXCP_DT_INT64, &t); }
14149881 115 void setFieldFromInt32Array(UINT32 fieldId, size_t numElements, const UINT32 *elements);
e30c2442 116 void setFieldFromInt32Array(UINT32 fieldId, const IntegerArray<UINT32> *data);
8f238fd7 117 bool setFieldFromFile(UINT32 fieldId, const TCHAR *pszFileName);
967893bb 118
ca0a165b
VK
119 INT16 getFieldAsInt16(UINT32 fieldId) const;
120 UINT16 getFieldAsUInt16(UINT32 fieldId) const;
121 INT32 getFieldAsInt32(UINT32 fieldId) const;
122 UINT32 getFieldAsUInt32(UINT32 fieldId) const;
123 INT64 getFieldAsInt64(UINT32 fieldId) const;
124 UINT64 getFieldAsUInt64(UINT32 fieldId) const;
125 double getFieldAsDouble(UINT32 fieldId) const;
126 bool getFieldAsBoolean(UINT32 fieldId) const;
127 time_t getFieldAsTime(UINT32 fieldId) const;
128 UINT32 getFieldAsInt32Array(UINT32 fieldId, UINT32 numElements, UINT32 *buffer) const;
129 UINT32 getFieldAsInt32Array(UINT32 fieldId, IntegerArray<UINT32> *data) const;
130 const BYTE *getBinaryFieldPtr(UINT32 fieldId, size_t *size) const;
131 TCHAR *getFieldAsString(UINT32 fieldId, TCHAR *buffer = NULL, size_t bufferSize = 0) const;
132 char *getFieldAsMBString(UINT32 fieldId, char *buffer = NULL, size_t bufferSize = 0) const;
133 char *getFieldAsUtf8String(UINT32 fieldId, char *buffer = NULL, size_t bufferSize = 0) const;
134 UINT32 getFieldAsBinary(UINT32 fieldId, BYTE *buffer, size_t bufferSize) const;
135 InetAddress getFieldAsInetAddress(UINT32 fieldId) const;
136 uuid getFieldAsGUID(UINT32 fieldId) const;
4101571e 137
b368969c 138 void deleteAllFields();
e44ac467 139
5c44534b
VK
140 void disableEncryption() { m_flags |= MF_DONT_ENCRYPT; }
141 void setEndOfSequence() { m_flags |= MF_END_OF_SEQUENCE; }
142 void setReverseOrderFlag() { m_flags |= MF_REVERSE_ORDER; }
934f53da 143
ca0a165b 144 static String dump(const NXCP_MESSAGE *msg, int version);
0d9c1b96
VK
145};
146
4af351c7
VK
147/**
148 * Message waiting queue element structure
149 */
deaa4491
VK
150typedef struct
151{
b368969c 152 void *msg; // Pointer to message, either to NXCPMessage object or raw message
14149881 153 UINT64 sequence; // Sequence number
f128c07c
VK
154 UINT32 id; // Message ID
155 UINT32 ttl; // Message time-to-live in milliseconds
156 UINT16 code; // Message code
157 UINT16 isBinary; // 1 for binary (raw) messages
deaa4491
VK
158} WAIT_QUEUE_ELEMENT;
159
4af351c7 160/**
f128c07c
VK
161 * Max number of waiting threads in message queue
162 */
163#define MAX_MSGQUEUE_WAITERS 32
164
165/**
4af351c7
VK
166 * Message waiting queue class
167 */
9f2ad16c 168class LIBNETXMS_EXPORTABLE MsgWaitQueue
deaa4491 169{
deaa4491 170private:
ef8a3c32 171#if defined(_WIN32)
f128c07c
VK
172 CRITICAL_SECTION m_mutex;
173 HANDLE m_wakeupEvents[MAX_MSGQUEUE_WAITERS];
174 BYTE m_waiters[MAX_MSGQUEUE_WAITERS];
ef8a3c32
VK
175#elif defined(_USE_GNU_PTH)
176 pth_mutex_t m_mutex;
177 pth_cond_t m_wakeupCondition;
f128c07c
VK
178#else
179 pthread_mutex_t m_mutex;
180 pthread_cond_t m_wakeupCondition;
181#endif
f128c07c
VK
182 UINT32 m_holdTime;
183 int m_size;
184 int m_allocated;
185 WAIT_QUEUE_ELEMENT *m_elements;
14149881 186 UINT64 m_sequence;
deaa4491 187
f128c07c
VK
188 void *waitForMessageInternal(UINT16 isBinary, UINT16 code, UINT32 id, UINT32 timeout);
189
190 void lock()
191 {
192#ifdef _WIN32
193 EnterCriticalSection(&m_mutex);
ef8a3c32
VK
194#elif defined(_USE_GNU_PTH)
195 pth_mutex_acquire(&m_mutex, FALSE, NULL);
f128c07c
VK
196#else
197 pthread_mutex_lock(&m_mutex);
198#endif
199 }
200
201 void unlock()
202 {
203#ifdef _WIN32
204 LeaveCriticalSection(&m_mutex);
ef8a3c32
VK
205#elif defined(_USE_GNU_PTH)
206 pth_mutex_release(&m_mutex);
f128c07c
VK
207#else
208 pthread_mutex_unlock(&m_mutex);
209#endif
210 }
cc022855 211
d87ddcc2
VK
212 void housekeeperRun();
213
c73c3ba9 214 static Mutex m_housekeeperLock;
669fcb92 215 static HashMap<UINT64, MsgWaitQueue> *m_activeQueues;
c73c3ba9 216 static Condition m_shutdownCondition;
d87ddcc2
VK
217 static THREAD m_housekeeperThread;
218 static EnumerationCallbackResult houseKeeperCallback(const void *key, const void *object, void *arg);
219 static THREAD_RESULT THREAD_CALL housekeeperThread(void *);
220 static EnumerationCallbackResult diagInfoCallback(const void *key, const void *object, void *arg);
deaa4491
VK
221
222public:
223 MsgWaitQueue();
224 ~MsgWaitQueue();
225
b368969c
VK
226 void put(NXCPMessage *pMsg);
227 void put(NXCP_MESSAGE *pMsg);
228 NXCPMessage *waitForMessage(WORD wCode, UINT32 dwId, UINT32 dwTimeOut)
deaa4491 229 {
b368969c 230 return (NXCPMessage *)waitForMessageInternal(0, wCode, dwId, dwTimeOut);
deaa4491 231 }
b368969c 232 NXCP_MESSAGE *waitForRawMessage(WORD wCode, UINT32 dwId, UINT32 dwTimeOut)
deaa4491 233 {
b368969c 234 return (NXCP_MESSAGE *)waitForMessageInternal(1, wCode, dwId, dwTimeOut);
deaa4491 235 }
cc022855 236
c17f6cbc 237 void clear();
f128c07c 238 void setHoldTime(UINT32 holdTime) { m_holdTime = holdTime; }
d87ddcc2
VK
239
240 static void shutdown();
241 static String getDiagInfo();
deaa4491
VK
242};
243
b549a0f8
VK
244/**
245 * NXCP encryption context
246 */
98abc9f1
VK
247class LIBNETXMS_EXPORTABLE NXCPEncryptionContext : public RefCountObject
248{
249private:
250 int m_cipher;
251 BYTE *m_sessionKey;
252 int m_keyLength;
253 BYTE m_iv[EVP_MAX_IV_LENGTH];
e4e091f0 254#ifdef _WITH_ENCRYPTION
9c3bf7f4
VK
255 MUTEX m_encryptorLock;
256#if WITH_OPENSSL
e6336a90
VK
257 EVP_CIPHER_CTX m_encryptor;
258 EVP_CIPHER_CTX m_decryptor;
9c3bf7f4
VK
259#elif WITH_COMMONCRYPTO
260 CCCryptorRef m_encryptor;
261 CCCryptorRef m_decryptor;
262#endif
e4e091f0 263#endif
98abc9f1
VK
264
265 NXCPEncryptionContext();
e6336a90 266 bool initCipher(int cipher);
98abc9f1
VK
267
268public:
b368969c 269 static NXCPEncryptionContext *create(NXCPMessage *msg, RSA *privateKey);
967893bb 270 static NXCPEncryptionContext *create(UINT32 ciphers);
98abc9f1
VK
271
272 virtual ~NXCPEncryptionContext();
273
b368969c 274 NXCP_ENCRYPTED_MESSAGE *encryptMessage(NXCP_MESSAGE *msg);
6be0a20b 275 bool decryptMessage(NXCP_ENCRYPTED_MESSAGE *msg, BYTE *decryptionBuffer);
e6336a90 276
98abc9f1
VK
277 int getCipher() { return m_cipher; }
278 BYTE *getSessionKey() { return m_sessionKey; }
279 int getKeyLength() { return m_keyLength; }
280 BYTE *getIV() { return m_iv; }
281};
282
6be0a20b
VK
283/**
284 * Message receiver result codes
285 */
286enum MessageReceiverResult
287{
288 MSGRECV_SUCCESS = 0,
289 MSGRECV_CLOSED = 1,
290 MSGRECV_TIMEOUT = 2,
291 MSGRECV_COMM_FAILURE = 3,
1bb62997
VK
292 MSGRECV_DECRYPTION_FAILURE = 4,
293 MSGRECV_PROTOCOL_ERROR = 5
6be0a20b
VK
294};
295
296/**
297 * Message receiver - abstract base class
298 */
299class LIBNETXMS_EXPORTABLE AbstractMessageReceiver
300{
301private:
302 BYTE *m_buffer;
303 BYTE *m_decryptionBuffer;
304 NXCPEncryptionContext *m_encryptionContext;
305 size_t m_initialSize;
306 size_t m_size;
307 size_t m_maxSize;
308 size_t m_dataSize;
309 size_t m_bytesToSkip;
310
1bb62997 311 NXCPMessage *getMessageFromBuffer(bool *protocolError);
6be0a20b
VK
312
313protected:
314 virtual int readBytes(BYTE *buffer, size_t size, UINT32 timeout) = 0;
315
316public:
317 AbstractMessageReceiver(size_t initialSize, size_t maxSize);
318 virtual ~AbstractMessageReceiver();
319
320 void setEncryptionContext(NXCPEncryptionContext *ctx) { m_encryptionContext = ctx; }
321
b368969c
VK
322 NXCPMessage *readMessage(UINT32 timeout, MessageReceiverResult *result);
323 NXCP_MESSAGE *getRawMessageBuffer() { return (NXCP_MESSAGE *)m_buffer; }
324
325 static const TCHAR *resultToText(MessageReceiverResult result);
6be0a20b
VK
326};
327
328/**
329 * Message receiver - socket implementation
330 */
331class LIBNETXMS_EXPORTABLE SocketMessageReceiver : public AbstractMessageReceiver
332{
333private:
334 SOCKET m_socket;
335
336protected:
337 virtual int readBytes(BYTE *buffer, size_t size, UINT32 timeout);
338
339public:
340 SocketMessageReceiver(SOCKET socket, size_t initialSize, size_t maxSize);
341 virtual ~SocketMessageReceiver();
342};
343
344/**
345 * Message receiver - UNIX socket/named pipe implementation
346 */
347class LIBNETXMS_EXPORTABLE PipeMessageReceiver : public AbstractMessageReceiver
348{
349private:
350 HPIPE m_pipe;
351#ifdef _WIN32
352 HANDLE m_readEvent;
353#endif
354
355protected:
356 virtual int readBytes(BYTE *buffer, size_t size, UINT32 timeout);
357
358public:
359 PipeMessageReceiver(HPIPE pipe, size_t initialSize, size_t maxSize);
360 virtual ~PipeMessageReceiver();
361};
362
503da871
VK
363/**
364 * NXCP compression methods
365 */
366enum NXCPCompressionMethod
367{
368 NXCP_COMPRESSION_NONE = 0,
369 NXCP_COMPRESSION_LZ4 = 1
370};
371
372/**
373 * Abstract stream compressor
374 */
375class LIBNETXMS_EXPORTABLE StreamCompressor
376{
377public:
9757ca46
VK
378 virtual ~StreamCompressor();
379
503da871
VK
380 virtual size_t compress(const BYTE *in, size_t inSize, BYTE *out, size_t maxOutSize) = 0;
381 virtual size_t decompress(const BYTE *in, size_t inSize, const BYTE **out) = 0;
382 virtual size_t compressBufferSize(size_t dataSize) = 0;
383
384 static StreamCompressor *create(NXCPCompressionMethod method, bool compress, size_t maxBlockSize);
385};
386
387/**
388 * Dummy stream compressor
389 */
390class LIBNETXMS_EXPORTABLE DummyStreamCompressor : public StreamCompressor
391{
392public:
9757ca46
VK
393 virtual ~DummyStreamCompressor();
394
503da871
VK
395 virtual size_t compress(const BYTE *in, size_t inSize, BYTE *out, size_t maxOutSize);
396 virtual size_t decompress(const BYTE *in, size_t inSize, const BYTE **out);
397 virtual size_t compressBufferSize(size_t dataSize);
398};
399
400struct __LZ4_stream_t;
401struct __LZ4_streamDecode_t;
402
403/**
404 * LZ4 stream compressor
405 */
406class LIBNETXMS_EXPORTABLE LZ4StreamCompressor : public StreamCompressor
407{
408private:
409 union
410 {
411 __LZ4_stream_t *encoder;
412 __LZ4_streamDecode_t *decoder;
413 } m_stream;
414 char *m_buffer;
415 size_t m_maxBlockSize;
416 size_t m_bufferSize;
417 size_t m_bufferPos;
418 bool m_compress;
419
420public:
421 LZ4StreamCompressor(bool compress, size_t maxBlockSize);
422 virtual ~LZ4StreamCompressor();
423
424 virtual size_t compress(const BYTE *in, size_t inSize, BYTE *out, size_t maxOutSize);
425 virtual size_t decompress(const BYTE *in, size_t inSize, const BYTE **out);
426 virtual size_t compressBufferSize(size_t dataSize);
427};
428
208d7427
VK
429#if 0
430/**
431 * NXCP message consumer interface
432 */
433class LIBNETXMS_EXPORTABLE MessageConsumer
434{
435public:
436 virtual SOCKET getSocket() = 0;
437 virtual void processMessage(NXCPMessage *msg) = 0;
438};
439
440/**
441 * Socket receiver - manages receiving NXCP messages from multiple sockets
442 */
443class LIBNETXMS_EXPORTABLE SocketReceiver
444{
445private:
446 THREAD m_thread;
447 HashMap<SOCKET, MessageConsumer> *m_consumers;
448
449 static int m_maxSocketsPerThread;
450 static ObjectArray<SocketReceiver> *m_receivers;
451
452public:
453 static void start();
454 static void shutdown();
455
456 static void addConsumer(MessageConsumer *mc);
457 static void removeConsumer(MessageConsumer *mc);
458
459 static String getDiagInfo();
460};
461#endif
462
9f2ad16c
VK
463#else /* __cplusplus */
464
b368969c 465typedef void NXCPMessage;
98abc9f1 466typedef void NXCPEncryptionContext;
9f2ad16c
VK
467
468#endif
469
da9ac8fc
VK
470typedef bool (*NXCPMessageNameResolver)(UINT16 code, TCHAR *buffer);
471
deaa4491
VK
472
473//
0d9c1b96
VK
474// Functions
475//
476
477#ifdef __cplusplus
0d9c1b96 478
b368969c
VK
479int LIBNETXMS_EXPORTABLE RecvNXCPMessage(SOCKET hSocket, NXCP_MESSAGE *pMsg,
480 NXCP_BUFFER *pBuffer, UINT32 dwMaxMsgSize,
98abc9f1 481 NXCPEncryptionContext **ppCtx,
967893bb 482 BYTE *pDecryptionBuffer, UINT32 dwTimeout);
b368969c
VK
483int LIBNETXMS_EXPORTABLE RecvNXCPMessageEx(SOCKET hSocket, NXCP_MESSAGE **msgBuffer,
484 NXCP_BUFFER *nxcpBuffer, UINT32 *bufferSize,
cc022855 485 NXCPEncryptionContext **ppCtx,
967893bb
VK
486 BYTE **decryptionBuffer, UINT32 dwTimeout,
487 UINT32 maxMsgSize);
b368969c 488NXCP_MESSAGE LIBNETXMS_EXPORTABLE *CreateRawNXCPMessage(WORD wCode, UINT32 dwId, WORD flags,
967893bb 489 UINT32 dwDataSize, void *pData,
b368969c 490 NXCP_MESSAGE *pBuffer);
967893bb 491BOOL LIBNETXMS_EXPORTABLE SendFileOverNXCP(SOCKET hSocket, UINT32 dwId, const TCHAR *pszFile,
cc022855 492 NXCPEncryptionContext *pCtx, long offset,
7b8b337e 493 void (* progressCallback)(INT64, void *), void *cbArg,
503da871 494 MUTEX mutex, NXCPCompressionMethod compressionMethod = NXCP_COMPRESSION_NONE);
7b8b337e 495BOOL LIBNETXMS_EXPORTABLE NXCPGetPeerProtocolVersion(SOCKET hSocket, int *pnVersion, MUTEX mutex);
cc022855 496
da9ac8fc
VK
497TCHAR LIBNETXMS_EXPORTABLE *NXCPMessageCodeName(UINT16 wCode, TCHAR *buffer);
498void LIBNETXMS_EXPORTABLE NXCPRegisterMessageNameResolver(NXCPMessageNameResolver r);
499void LIBNETXMS_EXPORTABLE NXCPUnregisterMessageNameResolver(NXCPMessageNameResolver r);
500
2df047f4 501bool LIBNETXMS_EXPORTABLE InitCryptoLib(UINT32 dwEnabledCiphers);
e5390fb5
VK
502UINT32 LIBNETXMS_EXPORTABLE NXCPGetSupportedCiphers();
503String LIBNETXMS_EXPORTABLE NXCPGetSupportedCiphersAsText();
b368969c 504NXCP_ENCRYPTED_MESSAGE LIBNETXMS_EXPORTABLE *NXCPEncryptMessage(NXCPEncryptionContext *pCtx, NXCP_MESSAGE *pMsg);
bf6fb6c3 505bool LIBNETXMS_EXPORTABLE NXCPDecryptMessage(NXCPEncryptionContext *pCtx,
6be0a20b 506 NXCP_ENCRYPTED_MESSAGE *pMsg,
e44ac467 507 BYTE *pDecryptionBuffer);
b368969c 508UINT32 LIBNETXMS_EXPORTABLE SetupEncryptionContext(NXCPMessage *pMsg,
98abc9f1 509 NXCPEncryptionContext **ppCtx,
b368969c 510 NXCPMessage **ppResponse,
4bd3d6c5 511 RSA *pPrivateKey, int nNXCPVersion);
b368969c 512void LIBNETXMS_EXPORTABLE PrepareKeyRequestMsg(NXCPMessage *pMsg, RSA *pServerKey, bool useX509Format);
3aa0061c 513RSA LIBNETXMS_EXPORTABLE *LoadRSAKeys(const TCHAR *pszKeyFile);
15cf5acc 514
bb8136f7 515#ifdef _WIN32
967893bb 516BOOL LIBNETXMS_EXPORTABLE SignMessageWithCAPI(BYTE *pMsg, UINT32 dwMsgLen, const CERT_CONTEXT *pCert,
b368969c 517 BYTE *pBuffer, size_t bufferSize, UINT32 *pdwSigLen);
bb8136f7
VK
518#endif
519
0d9c1b96
VK
520#endif
521
9f2ad16c 522#endif /* _nxcpapi_h_ */