preparation for object serialization to JSON
[public/netxms.git] / src / server / include / nms_objects.h
CommitLineData
3f39fdc2 1/*
5039dede 2** NetXMS - Network Management System
e2c2154a 3** Copyright (C) 2003-2014 Victor Kirhenshtein
5039dede
AK
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** File: nms_objects.h
20**
21**/
22
23#ifndef _nms_objects_h_
24#define _nms_objects_h_
25
26#include <nms_agent.h>
5039dede 27#include <netxms_maps.h>
e2babedf 28#include <geolocation.h>
e9ef47dd 29#include <jansson.h>
ab621f39 30#include "nxcore_jobs.h"
630e15d6 31#include "nms_topo.h"
5039dede 32
6fd6de0a
VK
33/**
34 * Forward declarations of classes
35 */
5039dede
AK
36class ClientSession;
37class Queue;
6fd6de0a 38class DataCollectionTarget;
5039dede 39
6fd6de0a 40/**
dcc8b1bc 41 * Global variables used by inline methods
6fd6de0a 42 */
967893bb
VK
43extern UINT32 g_dwDiscoveryPollingInterval;
44extern UINT32 g_dwStatusPollingInterval;
45extern UINT32 g_dwConfigurationPollingInterval;
46extern UINT32 g_dwRoutingTableUpdateInterval;
47extern UINT32 g_dwTopologyPollingInterval;
48extern UINT32 g_dwConditionPollingInterval;
805171de 49extern UINT32 g_instancePollingInterval;
9708eff4 50extern INT16 g_defaultAgentCacheMode;
5039dede 51
dcc8b1bc
VK
52/**
53 * Utility functions used by inline methods
54 */
55bool NXCORE_EXPORTABLE ExecuteQueryOnObject(DB_HANDLE hdb, UINT32 objectId, const TCHAR *query);
56
6fd6de0a
VK
57/**
58 * Constants
59 */
5039dede
AK
60#define MAX_INTERFACES 4096
61#define MAX_ATTR_NAME_LEN 128
62#define INVALID_INDEX 0xFFFFFFFF
63
7243b4ad
VK
64/**
65 * Last events
66 */
5039dede
AK
67#define MAX_LAST_EVENTS 8
68
69#define LAST_EVENT_NODE_DOWN 0
66d15dff 70#define LAST_EVENT_AGENT_DOWN 1
5039dede 71
7243b4ad
VK
72/**
73 * Built-in object IDs
74 */
5a4dc0c6
VK
75#define BUILTIN_OID_NETWORK 1
76#define BUILTIN_OID_SERVICEROOT 2
77#define BUILTIN_OID_TEMPLATEROOT 3
78#define BUILTIN_OID_ZONE0 4
79#define BUILTIN_OID_POLICYROOT 5
80#define BUILTIN_OID_NETWORKMAPROOT 6
81#define BUILTIN_OID_DASHBOARDROOT 7
5a4dc0c6 82#define BUILTIN_OID_BUSINESSSERVICEROOT 9
5039dede 83
0eff2ce4
VK
84/**
85 * "All zones" pseudo-ID
86 */
87#define ALL_ZONES ((UINT32)0xFFFFFFFF)
88
17ac348b
VK
89/**
90 * Node runtime (dynamic) flags
91 */
805171de
VK
92#define NDF_QUEUED_FOR_STATUS_POLL 0x000001
93#define NDF_QUEUED_FOR_CONFIG_POLL 0x000002
94#define NDF_UNREACHABLE 0x000004
95#define NDF_AGENT_UNREACHABLE 0x000008
96#define NDF_SNMP_UNREACHABLE 0x000010
97#define NDF_QUEUED_FOR_DISCOVERY_POLL 0x000020
98#define NDF_FORCE_STATUS_POLL 0x000040
99#define NDF_FORCE_CONFIGURATION_POLL 0x000080
100#define NDF_QUEUED_FOR_ROUTE_POLL 0x000100
101#define NDF_CPSNMP_UNREACHABLE 0x000200
102#define NDF_RECHECK_CAPABILITIES 0x000400
103#define NDF_POLLING_DISABLED 0x000800
104#define NDF_CONFIGURATION_POLL_PASSED 0x001000
105#define NDF_QUEUED_FOR_TOPOLOGY_POLL 0x002000
106#define NDF_DELETE_IN_PROGRESS 0x004000
107#define NDF_NETWORK_PATH_PROBLEM 0x008000
108#define NDF_QUEUED_FOR_INSTANCE_POLL 0x010000
ed5577cf 109#define NDF_CACHE_MODE_NOT_SUPPORTED 0x020000
5039dede 110
ed5577cf 111#define NDF_PERSISTENT (NDF_UNREACHABLE | NDF_NETWORK_PATH_PROBLEM | NDF_AGENT_UNREACHABLE | NDF_SNMP_UNREACHABLE | NDF_CPSNMP_UNREACHABLE | NDF_CACHE_MODE_NOT_SUPPORTED)
4866d57b 112
d41923e1
VK
113#define __NDF_FLAGS_DEFINED
114
17ac348b
VK
115/**
116 * Cluster runtime flags
117 */
fcfb317c
VK
118#define CLF_QUEUED_FOR_STATUS_POLL 0x0001
119#define CLF_DOWN 0x0002
120#define CLF_QUEUED_FOR_CONFIGURATION_POLL 0x0004
208d7427 121
2f6c6597
VK
122class AgentTunnel;
123
a416f8f6
VK
124/**
125 * Extended agent connection
126 */
127class NXCORE_EXPORTABLE AgentConnectionEx : public AgentConnection
128{
129protected:
130 UINT32 m_nodeId;
2f6c6597 131 AgentTunnel *m_tunnel;
ed83ffcd 132 AgentTunnel *m_proxyTunnel;
a416f8f6 133
2f6c6597 134 virtual AbstractCommChannel *createChannel();
a416f8f6 135 virtual void onTrap(NXCPMessage *msg);
685508a7 136 virtual void onSyslogMessage(NXCPMessage *pMsg);
a416f8f6
VK
137 virtual void onDataPush(NXCPMessage *msg);
138 virtual void onFileMonitoringData(NXCPMessage *msg);
139 virtual void onSnmpTrap(NXCPMessage *pMsg);
140 virtual UINT32 processCollectedData(NXCPMessage *msg);
a1273b42 141 virtual UINT32 processBulkCollectedData(NXCPMessage *request, NXCPMessage *response);
a416f8f6
VK
142 virtual bool processCustomMessage(NXCPMessage *msg);
143
7dd6369a
VK
144 virtual ~AgentConnectionEx();
145
a416f8f6 146public:
2f6c6597
VK
147 AgentConnectionEx(UINT32 nodeId, const InetAddress& ipAddr, WORD port = AGENT_LISTEN_PORT, int authMethod = AUTH_NONE, const TCHAR *secret = NULL, bool allowCompression = true);
148 AgentConnectionEx(UINT32 nodeId, AgentTunnel *tunnel, int authMethod = AUTH_NONE, const TCHAR *secret = NULL, bool allowCompression = true);
a416f8f6
VK
149
150 UINT32 deployPolicy(AgentPolicy *policy);
151 UINT32 uninstallPolicy(AgentPolicy *policy);
2f6c6597
VK
152
153 void setTunnel(AgentTunnel *tunnel);
ed83ffcd
VK
154
155 using AgentConnection::setProxy;
b76ba8c2 156 void setProxy(AgentTunnel *tunnel, int authMethod, const TCHAR *secret);
a416f8f6
VK
157};
158
208d7427
VK
159/**
160 * Poller types
161 */
162enum PollerType
163{
164 POLLER_TYPE_STATUS = 0,
165 POLLER_TYPE_CONFIGURATION = 1,
166 POLLER_TYPE_INSTANCE_DISCOVERY = 2,
167 POLLER_TYPE_ROUTING_TABLE = 3,
168 POLLER_TYPE_DISCOVERY = 4,
169 POLLER_TYPE_BUSINESS_SERVICE = 5,
170 POLLER_TYPE_CONDITION = 6,
171 POLLER_TYPE_TOPOLOGY = 7
172};
173
174/**
175 * Poller information
176 */
8decad24 177class NXCORE_EXPORTABLE PollerInfo
208d7427
VK
178{
179private:
180 PollerType m_type;
181 NetObj *m_object;
182 TCHAR m_status[128];
183
184public:
185 PollerInfo(PollerType type, NetObj *object) { m_type = type; m_object = object; _tcscpy(m_status, _T("awaiting execution")); }
186 ~PollerInfo();
187
465bd4ff 188 PollerType getType() const { return m_type; }
208d7427
VK
189 NetObj *getObject() const { return m_object; }
190 const TCHAR *getStatus() const { return m_status; }
191
192 void startExecution() { _tcscpy(m_status, _T("started")); }
193 void setStatus(const TCHAR *status) { nx_strncpy(m_status, status, 128); }
194};
5039dede 195
17ac348b
VK
196/**
197 * Status poll types
198 */
199enum StatusPollType
200{
201 POLL_ICMP_PING = 0,
202 POLL_SNMP = 1,
203 POLL_NATIVE_AGENT =2
204};
5039dede 205
a84c073c
VK
206/**
207 * Auto bind/apply decisions
208 */
209enum AutoBindDecision
210{
211 AutoBindDecision_Ignore = -1,
212 AutoBindDecision_Unbind = 0,
213 AutoBindDecision_Bind = 1
214};
215
21c9acce
VK
216/**
217 * Zone types
218 */
5039dede
AK
219#define ZONE_TYPE_PASSIVE 0
220#define ZONE_TYPE_ACTIVE 1
221
21c9acce
VK
222/**
223 * Template update types
224 */
5039dede
AK
225#define APPLY_TEMPLATE 0
226#define REMOVE_TEMPLATE 1
227
6fd6de0a
VK
228/**
229 * Queued template update information
230 */
5039dede
AK
231struct TEMPLATE_UPDATE_INFO
232{
d140955e 233 int updateType;
5039dede 234 Template *pTemplate;
967893bb 235 UINT32 targetId;
d140955e 236 bool removeDCI;
5039dede
AK
237};
238
6fd6de0a 239/**
7243b4ad 240 * Object index element
6fd6de0a 241 */
5e39b8a3
VK
242struct INDEX_ELEMENT
243{
244 QWORD key;
245 NetObj *object;
246};
247
7243b4ad
VK
248/**
249 * Object index
250 */
5f0fc7a9 251class NXCORE_EXPORTABLE ObjectIndex
5e39b8a3
VK
252{
253private:
254 int m_size;
255 int m_allocated;
256 INDEX_ELEMENT *m_elements;
257 RWLOCK m_lock;
258
259 int findElement(QWORD key);
260
261public:
262 ObjectIndex();
263 ~ObjectIndex();
264
265 bool put(QWORD key, NetObj *object);
266 void remove(QWORD key);
267 NetObj *get(QWORD key);
268 NetObj *find(bool (*comparator)(NetObj *, void *), void *data);
f1984eb9 269 ObjectArray<NetObj> *findObjects(bool (*comparator)(NetObj *, void *), void *data);
5e39b8a3 270
a6312bd6 271 int size();
1201bac8 272 ObjectArray<NetObj> *getObjects(bool updateRefCount, bool (*filter)(NetObj *, void *) = NULL, void *userData = NULL);
5e39b8a3
VK
273
274 void forEach(void (*callback)(NetObj *, void *), void *data);
275};
276
c75e9ee4
VK
277struct InetAddressIndexEntry;
278
279/**
280 * Object index by IP address
281 */
282class NXCORE_EXPORTABLE InetAddressIndex
283{
284private:
285 InetAddressIndexEntry *m_root;
286 RWLOCK m_lock;
287
288public:
289 InetAddressIndex();
290 ~InetAddressIndex();
291
292 bool put(const InetAddress& addr, NetObj *object);
c30c0c0f 293 bool put(const InetAddressList *addrList, NetObj *object);
c75e9ee4 294 void remove(const InetAddress& addr);
c30c0c0f 295 void remove(const InetAddressList *addrList);
c75e9ee4
VK
296 NetObj *get(const InetAddress& addr);
297 NetObj *find(bool (*comparator)(NetObj *, void *), void *data);
298
299 int size();
300 ObjectArray<NetObj> *getObjects(bool updateRefCount, bool (*filter)(NetObj *, void *) = NULL, void *userData = NULL);
301
c30c0c0f 302 void forEach(void (*callback)(const InetAddress&, NetObj *, void *), void *data);
c75e9ee4
VK
303};
304
6fd6de0a
VK
305/**
306 * Node component
307 */
50d0de67
VK
308class Component
309{
310protected:
967893bb
VK
311 UINT32 m_index;
312 UINT32 m_class;
313 UINT32 m_ifIndex;
50d0de67
VK
314 TCHAR *m_name;
315 TCHAR *m_description;
316 TCHAR *m_model;
317 TCHAR *m_serial;
318 TCHAR *m_vendor;
319 TCHAR *m_firmware;
967893bb 320 UINT32 m_parentIndex;
50d0de67
VK
321 ObjectArray<Component> m_childs;
322
323public:
967893bb 324 Component(UINT32 index, const TCHAR *name);
50d0de67
VK
325 virtual ~Component();
326
967893bb 327 UINT32 updateFromSnmp(SNMP_Transport *snmp);
50d0de67
VK
328 void buildTree(ObjectArray<Component> *elements);
329
967893bb
VK
330 UINT32 getIndex() { return m_index; }
331 UINT32 getParentIndex() { return m_parentIndex; }
241e3ddb
EJ
332 NXSL_Array *getChildrenForNXSL();
333
334 UINT32 getClass() { return m_class; }
335 const TCHAR *getFirmware() { return m_firmware; }
336 const TCHAR *getModel() { return m_model; }
337 const TCHAR *getName() { return m_name; }
338 const TCHAR *getSerial() { return m_serial; }
339 const TCHAR *getVendor() { return m_vendor; }
50d0de67 340
b368969c 341 UINT32 fillMessage(NXCPMessage *msg, UINT32 baseId);
8836184f 342
50d0de67
VK
343 void print(CONSOLE_CTX console, int level);
344};
345
7243b4ad
VK
346/**
347 * Node component tree
348 */
8836184f
VK
349class ComponentTree : public RefCountObject
350{
351private:
352 Component *m_root;
353
354public:
355 ComponentTree(Component *root);
356 virtual ~ComponentTree();
357
b368969c 358 void fillMessage(NXCPMessage *msg, UINT32 baseId);
8836184f
VK
359 void print(CONSOLE_CTX console) { if (m_root != NULL) m_root->print(console, 0); }
360
361 bool isEmpty() { return m_root == NULL; }
362 Component *getRoot() { return m_root; }
363};
364
caa04e26
VK
365/**
366 * Software package information
367 */
368class SoftwarePackage
369{
370private:
371 TCHAR *m_name;
372 TCHAR *m_version;
373 TCHAR *m_vendor;
374 time_t m_date;
375 TCHAR *m_url;
376 TCHAR *m_description;
377
378public:
379 SoftwarePackage(Table *table, int row);
380 ~SoftwarePackage();
381
b368969c 382 void fillMessage(NXCPMessage *msg, UINT32 baseId);
caa04e26
VK
383};
384
914580f5
VK
385/**
386 * Summary table flags
387 */
388#define SUMMARY_TABLE_MULTI_INSTANCE 0x0001
389
2da939ac
VK
390/**
391 * Summary table column flags
392 */
393#define COLUMN_DEFINITION_REGEXP_MATCH 0x0001
394
4a435beb
VK
395/**
396 * Column definition for DCI summary table
397 */
398class NXCORE_EXPORTABLE SummaryTableColumn
399{
400public:
401 TCHAR m_name[MAX_DB_STRING];
402 TCHAR m_dciName[MAX_PARAM_NAME];
967893bb 403 UINT32 m_flags;
4a435beb 404
b368969c 405 SummaryTableColumn(NXCPMessage *msg, UINT32 baseId);
4a435beb 406 SummaryTableColumn(TCHAR *configStr);
2096c8f0
VK
407
408 void createExportRecord(String &xml, int id);
4a435beb
VK
409};
410
411/**
412 * DCI summary table class
413 */
414class NXCORE_EXPORTABLE SummaryTable
415{
416private:
2096c8f0 417 INT32 m_id;
de4af576 418 uuid m_guid;
4a435beb 419 TCHAR m_title[MAX_DB_STRING];
967893bb 420 UINT32 m_flags;
4a435beb 421 ObjectArray<SummaryTableColumn> *m_columns;
2096c8f0 422 TCHAR *m_filterSource;
6b29839d 423 NXSL_VM *m_filter;
2852ef09
VK
424 AggregationFunction m_aggregationFunction;
425 time_t m_periodStart;
426 time_t m_periodEnd;
2096c8f0 427 TCHAR m_menuPath[MAX_DB_STRING];
4a435beb 428
2096c8f0 429 SummaryTable(INT32 id, DB_RESULT hResult);
4a435beb
VK
430
431public:
2096c8f0 432 static SummaryTable *loadFromDB(INT32 id, UINT32 *rcc);
5389f7b0 433
b368969c 434 SummaryTable(NXCPMessage *msg);
4a435beb
VK
435 ~SummaryTable();
436
437 bool filter(DataCollectionTarget *node);
438 Table *createEmptyResultTable();
439
440 int getNumColumns() { return m_columns->size(); }
441 SummaryTableColumn *getColumn(int index) { return m_columns->get(index); }
2852ef09
VK
442 AggregationFunction getAggregationFunction() { return m_aggregationFunction; }
443 time_t getPeriodStart() { return m_periodStart; }
444 time_t getPeriodEnd() { return m_periodEnd; }
914580f5 445 bool isMultiInstance() { return (m_flags & SUMMARY_TABLE_MULTI_INSTANCE) ? true : false; }
2096c8f0
VK
446
447 void createExportRecord(String &xml);
4a435beb
VK
448};
449
d1c4701c
VK
450/**
451 * Object-associated URL
452 */
453class NXCORE_EXPORTABLE ObjectUrl
454{
455private:
456 UINT32 m_id;
457 TCHAR *m_url;
458 TCHAR *m_description;
459
460public:
461 ObjectUrl(NXCPMessage *msg, UINT32 baseId);
462 ObjectUrl(DB_RESULT hResult, int row);
463 ~ObjectUrl();
464
465 void fillMessage(NXCPMessage *msg, UINT32 baseId);
466
467 UINT32 getId() const { return m_id; }
468 const TCHAR *getUrl() const { return m_url; }
469 const TCHAR *getDescription() const { return m_description; }
470};
471
2df18cce
VK
472/**
473 * Base class for network objects
474 */
5039dede
AK
475class NXCORE_EXPORTABLE NetObj
476{
27de5dab
VK
477private:
478 static void onObjectDeleteCallback(NetObj *object, void *data);
479
fc381a38
VK
480 void getFullChildListInternal(ObjectIndex *list, bool eventSourceOnly);
481
5039dede 482protected:
c42b4551 483 UINT32 m_id;
de4af576 484 uuid m_guid;
967893bb
VK
485 UINT32 m_dwTimeStamp; // Last change time stamp
486 UINT32 m_dwRefCount; // Number of references. Object can be destroyed only when this counter is zero
c42b4551 487 TCHAR m_name[MAX_OBJECT_NAME];
db091a1f
VK
488 TCHAR *m_comments; // User comments
489 int m_status;
490 int m_statusCalcAlg; // Status calculation algorithm
491 int m_statusPropAlg; // Status propagation algorithm
492 int m_fixedStatus; // Status if propagation is "Fixed"
493 int m_statusShift; // Shift value for "shifted" status propagation
494 int m_statusTranslation[4];
495 int m_statusSingleThreshold;
496 int m_statusThresholds[4];
01152a54
VK
497 bool m_isModified;
498 bool m_isDeleted;
499 bool m_isHidden;
500 bool m_isSystem;
89fd6fa4 501 bool m_maintenanceMode;
97afcb6e 502 UINT64 m_maintenanceEventId;
de4af576 503 uuid m_image;
c42b4551 504 MUTEX m_mutexProperties; // Object data access mutex
5039dede
AK
505 MUTEX m_mutexRefCount; // Reference counter access mutex
506 RWLOCK m_rwlockParentList; // Lock for parent list
507 RWLOCK m_rwlockChildList; // Lock for child list
e2babedf 508 GeoLocation m_geoLocation;
56fa1092 509 PostalAddress *m_postalAddress;
c59466d2 510 ClientSession *m_pollRequestor;
967893bb 511 UINT32 m_submapId; // Map object which should be open on drill-down request
8bdd26dc 512 IntegerArray<UINT32> *m_dashboards; // Dashboards associated with this object
d1c4701c 513 ObjectArray<ObjectUrl> *m_urls; // URLs associated with this object
5039dede 514
db091a1f
VK
515 ObjectArray<NetObj> *m_childList; // Array of pointers to child objects
516 ObjectArray<NetObj> *m_parentList; // Array of pointers to parent objects
5039dede 517
19a2cd39
VK
518 AccessList *m_accessList;
519 bool m_inheritAccessRights;
5039dede
AK
520 MUTEX m_mutexACL;
521
967893bb
VK
522 UINT32 m_dwNumTrustedNodes; // Trusted nodes
523 UINT32 *m_pdwTrustedNodes;
3f39fdc2 524
5039dede 525 StringMap m_customAttributes;
4f5d216b 526 StringObjectMap<ModuleData> *m_moduleData;
5039dede 527
ca594353
VK
528 void lockProperties() const { MutexLock(m_mutexProperties); }
529 void unlockProperties() const { MutexUnlock(m_mutexProperties); }
e2c2154a
VK
530 void lockACL() { MutexLock(m_mutexACL); }
531 void unlockACL() { MutexUnlock(m_mutexACL); }
db091a1f 532 void lockParentList(bool writeLock)
3f39fdc2 533 {
db091a1f 534 if (writeLock)
5039dede
AK
535 RWLockWriteLock(m_rwlockParentList, INFINITE);
536 else
3f39fdc2 537 RWLockReadLock(m_rwlockParentList, INFINITE);
5039dede 538 }
db091a1f
VK
539 void unlockParentList() { RWLockUnlock(m_rwlockParentList); }
540 void lockChildList(bool writeLock)
3f39fdc2 541 {
db091a1f 542 if (writeLock)
5039dede
AK
543 RWLockWriteLock(m_rwlockChildList, INFINITE);
544 else
3f39fdc2 545 RWLockReadLock(m_rwlockChildList, INFINITE);
5039dede 546 }
db091a1f 547 void unlockChildList() { RWLockUnlock(m_rwlockChildList); }
5039dede 548
ba756b1a 549 void setModified(bool notify = true); // Used to mark object as modified
5039dede 550
9bd1bace 551 bool loadACLFromDB(DB_HANDLE hdb);
50546cb7 552 bool saveACLToDB(DB_HANDLE hdb);
9bd1bace 553 bool loadCommonProperties(DB_HANDLE hdb);
50546cb7 554 bool saveCommonProperties(DB_HANDLE hdb);
9bd1bace 555 bool loadTrustedNodes(DB_HANDLE hdb);
50546cb7 556 bool saveTrustedNodes(DB_HANDLE hdb);
c42b4551 557 bool executeQueryOnObject(DB_HANDLE hdb, const TCHAR *query) { return ExecuteQueryOnObject(hdb, m_id, query); }
5039dede 558
22ee6d97 559 virtual void prepareForDeletion();
967893bb 560 virtual void onObjectDelete(UINT32 dwObjectId);
e13420c1 561
8fe90adb 562 virtual void fillMessageInternal(NXCPMessage *msg);
9289a3bb 563 virtual void fillMessageInternalStage2(NXCPMessage *msg);
8fe90adb
VK
564 virtual UINT32 modifyFromMessageInternal(NXCPMessage *msg);
565
4899db4d 566 void addLocationToHistory();
d81f090f 567 bool isLocationTableExists(DB_HANDLE hdb);
7221dde1 568 bool createLocationHistoryTable(DB_HANDLE hdb);
5039dede
AK
569
570public:
571 NetObj();
572 virtual ~NetObj();
573
de4af576 574 virtual int getObjectClass() const { return OBJECT_GENERIC; }
666d54e2 575 virtual const TCHAR *getObjectClassName() const;
3f39fdc2 576
de4af576
VK
577 UINT32 getId() const { return m_id; }
578 const TCHAR *getName() const { return m_name; }
db091a1f 579 int getStatus() const { return m_status; }
6ff21d27 580 int getPropagatedStatus();
de4af576
VK
581 UINT32 getTimeStamp() const { return m_dwTimeStamp; }
582 const uuid& getGuid() const { return m_guid; }
db091a1f 583 const TCHAR *getComments() const { return CHECK_NULL_EX(m_comments); }
63e99e56
VK
584
585 const GeoLocation& getGeoLocation() const { return m_geoLocation; }
b5458c25 586 void setGeoLocation(const GeoLocation& geoLocation) { lockProperties(); m_geoLocation = geoLocation; setModified(); unlockProperties(); }
63e99e56
VK
587
588 const PostalAddress *getPostalAddress() const { return m_postalAddress; }
b5458c25
VK
589 void setPostalAddress(PostalAddress * addr) { lockProperties(); delete m_postalAddress; m_postalAddress = addr; setModified(); unlockProperties(); }
590
591 const uuid& getMapImage() { return m_image; }
592 void setMapImage(const uuid& image) { lockProperties(); m_image = image; setModified(); unlockProperties(); }
5039dede 593
63e99e56
VK
594 bool isModified() const { return m_isModified; }
595 bool isDeleted() const { return m_isDeleted; }
db091a1f
VK
596 bool isOrphaned() const { return m_parentList->size() == 0; }
597 bool isEmpty() const { return m_childList->size() == 0; }
3f39fdc2 598
63e99e56 599 bool isSystem() const { return m_isSystem; }
01152a54 600 void setSystemFlag(bool flag) { m_isSystem = flag; }
5039dede 601
967893bb 602 UINT32 getRefCount();
21c9acce
VK
603 void incRefCount();
604 void decRefCount();
5039dede 605
967893bb
VK
606 bool isChild(UINT32 id);
607 bool isTrustedNode(UINT32 id);
5039dede 608
1f8be1f4
VK
609 void addChild(NetObj *object); // Add reference to child object
610 void addParent(NetObj *object); // Add reference to parent object
5039dede 611
1f8be1f4
VK
612 void deleteChild(NetObj *object); // Delete reference to child object
613 void deleteParent(NetObj *object); // Delete reference to parent object
5039dede 614
9dea3344 615 void deleteObject(NetObj *initiator = NULL); // Prepare object for deletion
5039dede 616
01152a54 617 bool isHidden() { return m_isHidden; }
478d4ff4
VK
618 void hide();
619 void unhide();
99730c0c 620 void markAsModified() { lockProperties(); setModified(); unlockProperties(); } // external API to mark object as modified
5039dede 621
c42b4551
VK
622 virtual BOOL saveToDatabase(DB_HANDLE hdb);
623 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 624 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
32a400d9 625 virtual void linkObjects();
5039dede 626
c42b4551 627 void setId(UINT32 dwId) { m_id = dwId; setModified(); }
de4af576 628 void generateGuid() { m_guid = uuid::generate(); }
c42b4551 629 void setName(const TCHAR *pszName) { nx_strncpy(m_name, pszName, MAX_OBJECT_NAME); setModified(); }
db091a1f 630 void resetStatus() { m_status = STATUS_UNKNOWN; setModified(); }
c42b4551 631 void setComments(TCHAR *text); /* text must be dynamically allocated */
5039dede 632
489e7869
VK
633 bool isInMaintenanceMode() const { return m_maintenanceMode; }
634 UINT64 getMaintenanceEventId() const { return m_maintenanceEventId; }
97afcb6e
VK
635 virtual void enterMaintenanceMode();
636 virtual void leaveMaintenanceMode();
637
8fe90adb
VK
638 void fillMessage(NXCPMessage *msg);
639 UINT32 modifyFromMessage(NXCPMessage *msg);
5039dede 640
6ff21d27 641 virtual void postModify();
5039dede 642
b368969c 643 void commentsToMessage(NXCPMessage *pMsg);
5039dede 644
8fe90adb
VK
645 virtual void setMgmtStatus(BOOL bIsManaged);
646 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
647
967893bb
VK
648 UINT32 getUserRights(UINT32 dwUserId);
649 BOOL checkAccessRights(UINT32 dwUserId, UINT32 dwRequiredRights);
650 void dropUserAccess(UINT32 dwUserId);
5039dede 651
967893bb
VK
652 void addChildNodesToList(ObjectArray<Node> *nodeList, UINT32 dwUserId);
653 void addChildDCTargetsToList(ObjectArray<DataCollectionTarget> *dctList, UINT32 dwUserId);
3f39fdc2 654
84a815cd 655 const TCHAR *getCustomAttribute(const TCHAR *name) { return m_customAttributes.get(name); }
c42b4551
VK
656 void setCustomAttribute(const TCHAR *name, const TCHAR *value) { m_customAttributes.set(name, value); setModified(); }
657 void setCustomAttributePV(const TCHAR *name, TCHAR *value) { m_customAttributes.setPreallocated(_tcsdup(name), value); setModified(); }
658 void deleteCustomAttribute(const TCHAR *name) { m_customAttributes.remove(name); setModified(); }
ca594353 659 NXSL_Value *getCustomAttributesForNXSL() const;
5039dede 660
297a88eb
VK
661 virtual NXSL_Value *createNXSLObject();
662
4f5d216b
VK
663 ModuleData *getModuleData(const TCHAR *module);
664 void setModuleData(const TCHAR *module, ModuleData *data);
665
64e87664 666 ObjectArray<NetObj> *getParentList(int typeFilter);
fca08da9 667 ObjectArray<NetObj> *getChildList(int typeFilter);
da9cf449 668 ObjectArray<NetObj> *getFullChildList(bool eventSourceOnly, bool updateRefCount);
fc381a38 669
67de55fd 670 NetObj *findChildObject(const TCHAR *name, int typeFilter);
41c081df 671 Node *findChildNode(const InetAddress& addr);
67de55fd 672
db091a1f
VK
673 int getChildCount() { return m_childList->size(); }
674 int getParentCount() { return m_parentList->size(); }
9dea3344 675
06c104c6 676 virtual NXSL_Array *getParentsForNXSL();
d679defa 677 virtual NXSL_Array *getChildrenForNXSL();
06c104c6 678
27bbb906 679 virtual bool showThresholdSummary();
d1730ccf 680 virtual bool isEventSource();
db091a1f 681 virtual bool isDataCollectionTarget();
27bbb906 682
9d850e8b
VK
683 void setStatusCalculation(int method, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0);
684 void setStatusPropagation(int method, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0);
685
f7e3eb5a
VK
686 void sendPollerMsg(UINT32 dwRqId, const TCHAR *pszFormat, ...);
687
e9ef47dd
VK
688 virtual json_t *toJson();
689
5039dede 690 // Debug methods
fca08da9
VK
691 const TCHAR *dbgGetParentList(TCHAR *szBuffer);
692 const TCHAR *dbgGetChildList(TCHAR *szBuffer);
e4926628
VK
693
694 static const TCHAR *getObjectClassName(int objectClass);
5039dede
AK
695};
696
fca08da9
VK
697/**
698 * Get object's reference count
699 */
967893bb 700inline UINT32 NetObj::getRefCount()
3f39fdc2 701{
967893bb 702 UINT32 dwRefCount;
5039dede 703
c17f6cbc 704 MutexLock(m_mutexRefCount);
5039dede
AK
705 dwRefCount = m_dwRefCount;
706 MutexUnlock(m_mutexRefCount);
3f39fdc2 707 return dwRefCount;
5039dede
AK
708}
709
fca08da9
VK
710/**
711 * Increment object's reference count
712 */
21c9acce 713inline void NetObj::incRefCount()
3f39fdc2 714{
c17f6cbc 715 MutexLock(m_mutexRefCount);
5039dede
AK
716 m_dwRefCount++;
717 MutexUnlock(m_mutexRefCount);
718}
719
fca08da9
VK
720/**
721 * Decrement object's reference count
722 */
21c9acce 723inline void NetObj::decRefCount()
3f39fdc2 724{
c17f6cbc 725 MutexLock(m_mutexRefCount);
3f39fdc2 726 if (m_dwRefCount > 0)
727 m_dwRefCount--;
5039dede
AK
728 MutexUnlock(m_mutexRefCount);
729}
730
2df18cce
VK
731/**
732 * Data collection template class
733 */
5039dede
AK
734class NXCORE_EXPORTABLE Template : public NetObj
735{
736protected:
16d6f798 737 ObjectArray<DCObject> *m_dcObjects;
2a964810 738 int m_dciLockStatus;
967893bb
VK
739 UINT32 m_dwVersion;
740 UINT32 m_flags;
9fd816cc 741 bool m_dciListModified;
5039dede 742 TCHAR m_szCurrDCIOwner[MAX_SESSION_NAME];
4262c0dc 743 TCHAR *m_applyFilterSource;
9fc9ec2c 744 NXSL_Program *m_applyFilter;
b06436f4 745 RWLOCK m_dciAccessLock;
5039dede 746
22ee6d97 747 virtual void prepareForDeletion();
5039dede 748
8fe90adb
VK
749 virtual void fillMessageInternal(NXCPMessage *pMsg);
750 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
751
9fd816cc
VK
752 virtual void onDataCollectionChange();
753
9bd1bace 754 void loadItemsFromDB(DB_HANDLE hdb);
7c521895 755 void destroyItems();
e46d6c36 756 void updateInstanceDiscoveryItems(DCItem *dci);
7c521895 757
b06436f4
VK
758 void lockDciAccess(bool writeLock) { if (writeLock) { RWLockWriteLock(m_dciAccessLock, INFINITE); } else { RWLockReadLock(m_dciAccessLock, INFINITE); } }
759 void unlockDciAccess() { RWLockUnlock(m_dciAccessLock); }
5039dede 760
9fcf5d15 761 void deleteChildDCIs(UINT32 dcObjectId);
762 void destroyItem(DCObject *object, int index);
763
5039dede
AK
764public:
765 Template();
766 Template(const TCHAR *pszName);
9fedef8b 767 Template(ConfigEntry *config);
5039dede
AK
768 virtual ~Template();
769
de4af576 770 virtual int getObjectClass() const { return OBJECT_TEMPLATE; }
5039dede 771
c42b4551
VK
772 virtual BOOL saveToDatabase(DB_HANDLE hdb);
773 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 774 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
5039dede 775
27f9598d 776 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
5039dede 777
487cde95 778 UINT32 getFlags() const { return m_flags; }
7c521895
VK
779 int getVersionMajor() { return m_dwVersion >> 16; }
780 int getVersionMinor() { return m_dwVersion & 0xFFFF; }
5039dede 781
16d6f798
VK
782 int getItemCount() { return m_dcObjects->size(); }
783 bool addDCObject(DCObject *object, bool alreadyLocked = false);
b368969c 784 bool updateDCObject(UINT32 dwItemId, NXCPMessage *pMsg, UINT32 *pdwNumMaps, UINT32 **ppdwMapIndex, UINT32 **ppdwMapId);
967893bb
VK
785 bool deleteDCObject(UINT32 dcObjectId, bool needLock);
786 bool setItemStatus(UINT32 dwNumItems, UINT32 *pdwItemList, int iStatus);
787 int getItemType(UINT32 dwItemId);
0719f017 788 DCObject *getDCObjectById(UINT32 itemId, bool lock = true);
e7450f3b 789 DCObject *getDCObjectByGUID(const uuid& guid, bool lock = true);
967893bb 790 DCObject *getDCObjectByTemplateId(UINT32 tmplItemId);
16d6f798 791 DCObject *getDCObjectByIndex(int index);
abb85c62
VK
792 DCObject *getDCObjectByName(const TCHAR *name);
793 DCObject *getDCObjectByDescription(const TCHAR *description);
794 NXSL_Value *getAllDCObjectsForNXSL(const TCHAR *name, const TCHAR *description);
9fd816cc
VK
795 bool lockDCIList(int sessionId, const TCHAR *pszNewOwner, TCHAR *pszCurrOwner);
796 bool unlockDCIList(int sessionId);
797 void setDCIModificationFlag() { m_dciListModified = true; }
967893bb 798 void sendItemsToClient(ClientSession *pSession, UINT32 dwRqId);
47282713
VK
799 bool isLockedBySession(int sessionId) { return m_dciLockStatus == sessionId; }
800 IntegerArray<UINT32> *getDCIEventsList();
25a1e9d0 801 StringSet *getDCIScriptList();
5039dede 802
6fd6de0a 803 BOOL applyToTarget(DataCollectionTarget *pNode);
fcfb317c 804 AutoBindDecision isApplicable(DataCollectionTarget *object);
9b64b406
VK
805 bool isAutoApplyEnabled() { return (m_flags & TF_AUTO_APPLY) ? true : false; }
806 bool isAutoRemoveEnabled() { return ((m_flags & (TF_AUTO_APPLY | TF_AUTO_REMOVE)) == (TF_AUTO_APPLY | TF_AUTO_REMOVE)) ? true : false; }
fb05c05b 807 void setAutoApplyFilter(const TCHAR *filter);
7c521895 808 void queueUpdate();
d140955e 809 void queueRemoveFromTarget(UINT32 targetId, bool removeDCI);
171c2fd6 810
98ef8e4a
VK
811 void createExportRecord(String &str);
812 void updateFromImport(ConfigEntry *config);
3f39fdc2 813
967893bb 814 bool enumDCObjects(bool (* pfCallback)(DCObject *, UINT32, void *), void *pArg);
7c521895 815 void associateItems();
5dbf115e 816
1fa2ca0e 817 UINT32 getLastValues(NXCPMessage *msg, bool objectTooltipOnly, bool overviewOnly, bool includeNoValueObjects);
5039dede
AK
818};
819
c30c0c0f
VK
820class Cluster;
821
2df18cce
VK
822/**
823 * Interface class
824 */
5039dede
AK
825class NXCORE_EXPORTABLE Interface : public NetObj
826{
827protected:
c30c0c0f
VK
828 UINT32 m_index;
829 BYTE m_macAddr[MAC_ADDR_LENGTH];
830 InetAddressList m_ipAddressList;
967893bb 831 UINT32 m_flags;
478d4ff4 832 TCHAR m_description[MAX_DB_STRING]; // Interface description - value of ifDescr for SNMP, equals to name for NetXMS agent
e95680e5 833 TCHAR m_alias[MAX_DB_STRING]; // Interface alias - value of ifAlias for SNMP, empty for NetXMS agent
e95680e5
VK
834 UINT32 m_type;
835 UINT32 m_mtu;
3d37f7bf 836 UINT64 m_speed;
93be072b
VK
837 UINT32 m_bridgePortNumber; // 802.1D port number
838 UINT32 m_slotNumber; // Vendor/device specific slot number
839 UINT32 m_portNumber; // Vendor/device specific port number
840 UINT32 m_peerNodeId; // ID of peer node object, or 0 if unknown
841 UINT32 m_peerInterfaceId; // ID of peer interface object, or 0 if unknown
b833cbf5 842 LinkLayerProtocol m_peerDiscoveryProtocol; // Protocol used to discover peer node
93be072b
VK
843 INT16 m_adminState; // interface administrative state
844 INT16 m_operState; // interface operational state
845 INT16 m_pendingOperState;
846 INT16 m_confirmedOperState;
847 INT16 m_dot1xPaeAuthState; // 802.1x port auth state
848 INT16 m_dot1xBackendAuthState; // 802.1x backend auth state
c42b4551 849 UINT64 m_lastDownEventId;
c59466d2 850 int m_pendingStatus;
93be072b
VK
851 int m_statusPollCount;
852 int m_operStatePollCount;
c59466d2 853 int m_requiredPollCount;
967893bb 854 UINT32 m_zoneId;
1babf64d 855 UINT32 m_pingTime;
856 time_t m_pingLastTimeStamp;
3d37f7bf
VK
857 int m_ifTableSuffixLen;
858 UINT32 *m_ifTableSuffix;
5039dede 859
c30c0c0f
VK
860 void icmpStatusPoll(UINT32 rqId, UINT32 nodeIcmpProxy, Cluster *cluster, InterfaceAdminState *adminState, InterfaceOperState *operState);
861 void paeStatusPoll(UINT32 rqId, SNMP_Transport *pTransport, Node *node);
aa16f82b 862
95e0c288 863protected:
967893bb 864 virtual void onObjectDelete(UINT32 dwObjectId);
95e0c288 865
8fe90adb
VK
866 virtual void fillMessageInternal(NXCPMessage *pMsg);
867 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
868
de1be1b5
VK
869 void setExpectedStateInternal(int state);
870
5039dede
AK
871public:
872 Interface();
c30c0c0f
VK
873 Interface(const InetAddressList& addrList, UINT32 zoneId, bool bSyntheticMask);
874 Interface(const TCHAR *name, const TCHAR *descr, UINT32 index, const InetAddressList& addrList, UINT32 ifType, UINT32 zoneId);
5039dede
AK
875 virtual ~Interface();
876
de4af576 877 virtual int getObjectClass() const { return OBJECT_INTERFACE; }
c42b4551
VK
878 virtual BOOL saveToDatabase(DB_HANDLE hdb);
879 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 880 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
5039dede 881
e003f96a
VK
882 virtual NXSL_Value *createNXSLObject();
883
06a93345 884 Node *getParentNode();
035745fc 885 UINT32 getParentNodeId();
5039dede 886
c30c0c0f
VK
887 const InetAddressList *getIpAddressList() { return &m_ipAddressList; }
888 const InetAddress& getFirstIpAddress();
487cde95
VK
889 UINT32 getZoneId() const { return m_zoneId; }
890 UINT32 getIfIndex() const { return m_index; }
891 UINT32 getIfType() const { return m_type; }
892 UINT32 getMTU() const { return m_mtu; }
893 UINT64 getSpeed() const { return m_speed; }
894 UINT32 getBridgePortNumber() const { return m_bridgePortNumber; }
895 UINT32 getSlotNumber() const { return m_slotNumber; }
896 UINT32 getPortNumber() const { return m_portNumber; }
897 UINT32 getPeerNodeId() const { return m_peerNodeId; }
898 UINT32 getPeerInterfaceId() const { return m_peerInterfaceId; }
899 LinkLayerProtocol getPeerDiscoveryProtocol() const { return m_peerDiscoveryProtocol; }
900 UINT32 getFlags() const { return m_flags; }
e31d9b18 901 int getExpectedState() const { return (int)((m_flags & IF_EXPECTED_STATE_MASK) >> 28); }
487cde95
VK
902 int getAdminState() const { return (int)m_adminState; }
903 int getOperState() const { return (int)m_operState; }
904 int getConfirmedOperState() const { return (int)m_confirmedOperState; }
905 int getDot1xPaeAuthState() const { return (int)m_dot1xPaeAuthState; }
906 int getDot1xBackendAuthState() const { return (int)m_dot1xBackendAuthState; }
907 const TCHAR *getDescription() const { return m_description; }
908 const TCHAR *getAlias() const { return m_alias; }
909 const BYTE *getMacAddr() const { return m_macAddr; }
910 int getIfTableSuffixLen() const { return m_ifTableSuffixLen; }
911 const UINT32 *getIfTableSuffix() const { return m_ifTableSuffix; }
1babf64d 912 UINT32 getPingTime();
487cde95
VK
913 bool isSyntheticMask() const { return (m_flags & IF_SYNTHETIC_MASK) ? true : false; }
914 bool isPhysicalPort() const { return (m_flags & IF_PHYSICAL_PORT) ? true : false; }
915 bool isLoopback() const { return (m_flags & IF_LOOPBACK) ? true : false; }
916 bool isManuallyCreated() const { return (m_flags & IF_CREATED_MANUALLY) ? true : false; }
917 bool isExcludedFromTopology() const { return (m_flags & (IF_EXCLUDE_FROM_TOPOLOGY | IF_LOOPBACK)) ? true : false; }
918 bool isFake() const { return (m_index == 1) &&
919 (m_type == IFTYPE_OTHER) &&
d920bfaf 920 !_tcscmp(m_name, _T("unknown")); }
487cde95
VK
921
922 UINT64 getLastDownEventId() const { return m_lastDownEventId; }
f4b2ebd3 923 void setLastDownEventId(UINT64 id) { m_lastDownEventId = id; }
eec253a8 924
e55ff6f9 925 void setMacAddr(const BYTE *macAddr, bool updateMacDB);
c30c0c0f 926 void setIpAddress(const InetAddress& addr);
c42b4551
VK
927 void setBridgePortNumber(UINT32 bpn) { m_bridgePortNumber = bpn; setModified(); }
928 void setSlotNumber(UINT32 slot) { m_slotNumber = slot; setModified(); }
929 void setPortNumber(UINT32 port) { m_portNumber = port; setModified(); }
930 void setPhysicalPortFlag(bool isPhysical) { if (isPhysical) m_flags |= IF_PHYSICAL_PORT; else m_flags &= ~IF_PHYSICAL_PORT; setModified(); }
931 void setManualCreationFlag(bool isManual) { if (isManual) m_flags |= IF_CREATED_MANUALLY; else m_flags &= ~IF_CREATED_MANUALLY; setModified(); }
0717a453 932 void setPeer(Node *node, Interface *iface, LinkLayerProtocol protocol, bool reflection);
644f9e7a 933 void clearPeer() { lockProperties(); m_peerNodeId = 0; m_peerInterfaceId = 0; m_peerDiscoveryProtocol = LL_PROTO_UNKNOWN; setModified(); unlockProperties(); }
c42b4551 934 void setDescription(const TCHAR *descr) { lockProperties(); nx_strncpy(m_description, descr, MAX_DB_STRING); setModified(); unlockProperties(); }
e95680e5 935 void setAlias(const TCHAR *alias) { lockProperties(); nx_strncpy(m_alias, alias, MAX_DB_STRING); setModified(); unlockProperties(); }
c30c0c0f
VK
936 void addIpAddress(const InetAddress& addr);
937 void deleteIpAddress(InetAddress addr);
938 void setNetMask(const InetAddress& addr);
33560996 939 void setMTU(int mtu) { m_mtu = mtu; setModified(); }
3d37f7bf
VK
940 void setSpeed(UINT64 speed) { m_speed = speed; setModified(); }
941 void setIfTableSuffix(int len, const UINT32 *suffix) { lockProperties(); safe_free(m_ifTableSuffix); m_ifTableSuffixLen = len; m_ifTableSuffix = (len > 0) ? (UINT32 *)nx_memdup(suffix, len * sizeof(UINT32)) : NULL; setModified(); unlockProperties(); }
5039dede 942
4c789f9e
VK
943 void updateZoneId();
944
c30c0c0f 945 void statusPoll(ClientSession *session, UINT32 rqId, Queue *eventQueue, Cluster *cluster, SNMP_Transport *snmpTransport, UINT32 nodeIcmpProxy);
3f39fdc2 946
967893bb 947 UINT32 wakeUp();
de1be1b5 948 void setExpectedState(int state) { lockProperties(); setExpectedStateInternal(state); unlockProperties(); }
7638efb1 949 void setExcludeFromTopology(bool excluded);
1babf64d 950 void updatePingData();
5039dede
AK
951};
952
2df18cce
VK
953/**
954 * Network service class
955 */
b8014eee 956class NXCORE_EXPORTABLE NetworkService : public NetObj
5039dede
AK
957{
958protected:
c59466d2
VK
959 int m_serviceType; // SSH, POP3, etc.
960 Node *m_hostNode; // Pointer to node object which hosts this service
961 UINT32 m_pollerNode; // ID of node object which is used for polling
5039dede 962 // If 0, m_pHostNode->m_dwPollerNode will be used
c42b4551
VK
963 UINT16 m_proto; // Protocol (TCP, UDP, etc.)
964 UINT16 m_port; // TCP or UDP port number
c30c0c0f 965 InetAddress m_ipAddress;
c59466d2
VK
966 TCHAR *m_request; // Service-specific request
967 TCHAR *m_response; // Service-specific expected response
968 int m_pendingStatus;
969 int m_pollCount;
970 int m_requiredPollCount;
b8014eee 971 UINT32 m_responseTime; // Response time from last poll
5039dede 972
967893bb 973 virtual void onObjectDelete(UINT32 dwObjectId);
5039dede 974
8fe90adb
VK
975 virtual void fillMessageInternal(NXCPMessage *pMsg);
976 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
977
5039dede
AK
978public:
979 NetworkService();
980 NetworkService(int iServiceType, WORD wProto, WORD wPort,
981 TCHAR *pszRequest, TCHAR *pszResponse,
967893bb 982 Node *pHostNode = NULL, UINT32 dwPollerNode = 0);
5039dede
AK
983 virtual ~NetworkService();
984
de4af576 985 virtual int getObjectClass() const { return OBJECT_NETWORKSERVICE; }
5039dede 986
c42b4551
VK
987 virtual BOOL saveToDatabase(DB_HANDLE hdb);
988 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 989 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
5039dede 990
c59466d2 991 void statusPoll(ClientSession *session, UINT32 rqId, Node *pollerNode, Queue *eventQueue);
5039dede 992
b8014eee 993 UINT32 getResponseTime() { return m_responseTime; }
5039dede
AK
994};
995
2df18cce
VK
996/**
997 * VPN connector class
998 */
b8014eee 999class NXCORE_EXPORTABLE VPNConnector : public NetObj
5039dede
AK
1000{
1001protected:
967893bb 1002 UINT32 m_dwPeerGateway; // Object ID of peer gateway
c75e9ee4
VK
1003 ObjectArray<InetAddress> *m_localNetworks;
1004 ObjectArray<InetAddress> *m_remoteNetworks;
5039dede 1005
8fe90adb
VK
1006 virtual void fillMessageInternal(NXCPMessage *pMsg);
1007 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
1008
b8014eee 1009 Node *getParentNode();
5039dede
AK
1010
1011public:
1012 VPNConnector();
01152a54 1013 VPNConnector(bool hidden);
5039dede
AK
1014 virtual ~VPNConnector();
1015
de4af576 1016 virtual int getObjectClass() const { return OBJECT_VPNCONNECTOR; }
5039dede 1017
c42b4551
VK
1018 virtual BOOL saveToDatabase(DB_HANDLE hdb);
1019 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 1020 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
5039dede 1021
c75e9ee4
VK
1022 bool isLocalAddr(const InetAddress& addr);
1023 bool isRemoteAddr(const InetAddress& addr);
de4af576 1024 UINT32 getPeerGatewayId() const { return m_dwPeerGateway; }
c75e9ee4 1025 InetAddress getPeerGatewayAddr();
5039dede
AK
1026};
1027
46e2b370
VK
1028/**
1029 * Data collection proxy information structure
1030 */
1031struct ProxyInfo
1032{
1033 UINT32 proxyId;
1034 NXCPMessage *msg;
1035 UINT32 fieldId;
1036 UINT32 count;
1037 UINT32 nodeInfoFieldId;
1038 UINT32 nodeInfoCount;
1039};
1040
6fd6de0a
VK
1041/**
1042 * Common base class for all objects capable of collecting data
1043 */
1044class NXCORE_EXPORTABLE DataCollectionTarget : public Template
1045{
1046protected:
ebb2dc70
VK
1047 UINT32 m_pingTime;
1048 time_t m_pingLastTimeStamp;
1049
8fe90adb 1050 virtual void fillMessageInternal(NXCPMessage *pMsg);
9289a3bb 1051 virtual void fillMessageInternalStage2(NXCPMessage *pMsg);
8fe90adb
VK
1052 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
1053
6fd6de0a 1054 virtual bool isDataCollectionDisabled();
ebb2dc70 1055 virtual void updatePingData();
6fd6de0a 1056
b8014eee
VK
1057 NetObj *objectFromParameter(const TCHAR *param);
1058
3f61dbd4
VK
1059 NXSL_VM *runDataCollectionScript(const TCHAR *param);
1060
fcfb317c
VK
1061 void applyUserTemplates();
1062 void updateContainerMembership();
1063
46e2b370
VK
1064 void addProxyDataCollectionElement(ProxyInfo *info, const DCObject *dco);
1065 void addProxySnmpTarget(ProxyInfo *info, const Node *node);
1066 virtual void collectProxyInfo(ProxyInfo *info);
1067 static void collectProxyInfoCallback(NetObj *object, void *data);
1068
6fd6de0a
VK
1069public:
1070 DataCollectionTarget();
1071 DataCollectionTarget(const TCHAR *name);
1072 virtual ~DataCollectionTarget();
1073
c42b4551 1074 virtual bool deleteFromDatabase(DB_HANDLE hdb);
6fd6de0a 1075
f94d5259 1076 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
db091a1f 1077 virtual bool isDataCollectionTarget();
6fd6de0a 1078
d32e7ef1
VK
1079 virtual void enterMaintenanceMode();
1080 virtual void leaveMaintenanceMode();
1081
17b1ab4a
VK
1082 virtual UINT32 getInternalItem(const TCHAR *param, size_t bufSize, TCHAR *buffer);
1083 virtual UINT32 getScriptItem(const TCHAR *param, size_t bufSize, TCHAR *buffer);
3f61dbd4 1084 virtual UINT32 getScriptTable(const TCHAR *param, Table **result);
6fd6de0a 1085
46e2b370
VK
1086 virtual UINT32 getEffectiveSourceNode(DCObject *dco);
1087
d32e7ef1 1088 UINT32 getListFromScript(const TCHAR *param, StringList **list);
24bfa28b 1089 UINT32 getStringMapFromScript(const TCHAR *param, StringMap **map);
7e18667a 1090
b368969c
VK
1091 UINT32 getTableLastValues(UINT32 dciId, NXCPMessage *msg);
1092 UINT32 getThresholdSummary(NXCPMessage *msg, UINT32 baseId);
1093 UINT32 getPerfTabDCIList(NXCPMessage *pMsg);
2852ef09 1094 void getDciValuesSummary(SummaryTable *tableDefinition, Table *tableData);
6fd6de0a
VK
1095
1096 void updateDciCache();
77b2c6de 1097 void updateDCItemCacheSize(UINT32 dciId, UINT32 conditionId = 0);
5f648670 1098 void cleanDCIData(DB_HANDLE hdb);
2885ad2e 1099 void queueItemsForPolling(Queue *pollerQueue);
e63fca40 1100 bool processNewDCValue(DCObject *dco, time_t currTime, const void *value);
6fd6de0a 1101
967893bb
VK
1102 bool applyTemplateItem(UINT32 dwTemplateId, DCObject *dcObject);
1103 void cleanDeletedTemplateItems(UINT32 dwTemplateId, UINT32 dwNumItems, UINT32 *pdwItemList);
d140955e 1104 virtual void unbindFromTemplate(UINT32 dwTemplateId, bool removeDCI);
d1730ccf
VK
1105
1106 virtual bool isEventSource();
f94d5259 1107
cd68963b 1108 int getMostCriticalDCIStatus();
ebb2dc70
VK
1109
1110 UINT32 getPingTime();
6fd6de0a
VK
1111};
1112
2df18cce
VK
1113/**
1114 * Mobile device class
1115 */
6fd6de0a 1116class NXCORE_EXPORTABLE MobileDevice : public DataCollectionTarget
2df18cce
VK
1117{
1118protected:
1119 time_t m_lastReportTime;
1120 TCHAR *m_deviceId;
f22c4f7c 1121 TCHAR *m_vendor;
2df18cce 1122 TCHAR *m_model;
f22c4f7c
VK
1123 TCHAR *m_serialNumber;
1124 TCHAR *m_osName;
1125 TCHAR *m_osVersion;
1126 TCHAR *m_userId;
171c2fd6 1127 LONG m_batteryLevel;
c30c0c0f 1128 InetAddress m_ipAddress;
2df18cce 1129
8fe90adb
VK
1130 virtual void fillMessageInternal(NXCPMessage *pMsg);
1131 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
1132
2df18cce
VK
1133public:
1134 MobileDevice();
171c2fd6 1135 MobileDevice(const TCHAR *name, const TCHAR *deviceId);
2df18cce
VK
1136 virtual ~MobileDevice();
1137
de4af576 1138 virtual int getObjectClass() const { return OBJECT_MOBILEDEVICE; }
2df18cce 1139
9bd1bace 1140 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
c42b4551
VK
1141 virtual BOOL saveToDatabase(DB_HANDLE hdb);
1142 virtual bool deleteFromDatabase(DB_HANDLE hdb);
2df18cce 1143
26e2b253
VK
1144 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
1145
297a88eb
VK
1146 virtual NXSL_Value *createNXSLObject();
1147
b368969c
VK
1148 void updateSystemInfo(NXCPMessage *msg);
1149 void updateStatus(NXCPMessage *msg);
6583a0f8 1150
534e1b83 1151 const TCHAR *getDeviceId() { return CHECK_NULL_EX(m_deviceId); }
34f32920
Z
1152 const TCHAR *getVendor() { return CHECK_NULL_EX(m_vendor); }
1153 const TCHAR *getModel() { return CHECK_NULL_EX(m_model); }
1154 const TCHAR *getSerialNumber() { return CHECK_NULL_EX(m_serialNumber); }
1155 const TCHAR *getOsName() { return CHECK_NULL_EX(m_osName); }
1156 const TCHAR *getOsVersion() { return CHECK_NULL_EX(m_osVersion); }
1157 const TCHAR *getUserId() { return CHECK_NULL_EX(m_userId); }
1158 const LONG getBatteryLevel() { return m_batteryLevel; }
eb0c0312 1159
17b1ab4a 1160 virtual UINT32 getInternalItem(const TCHAR *param, size_t bufSize, TCHAR *buffer);
2df18cce
VK
1161};
1162
8715a84c
VK
1163/**
1164 * Access point class
1165 */
1166class NXCORE_EXPORTABLE AccessPoint : public DataCollectionTarget
1167{
1168protected:
ac58ffe9 1169 UINT32 m_index;
c30c0c0f 1170 InetAddress m_ipAddress;
967893bb 1171 UINT32 m_nodeId;
8715a84c
VK
1172 BYTE m_macAddr[MAC_ADDR_LENGTH];
1173 TCHAR *m_vendor;
1174 TCHAR *m_model;
1175 TCHAR *m_serialNumber;
d5de1d1d 1176 ObjectArray<RadioInterfaceInfo> *m_radioInterfaces;
23ed00c4 1177 AccessPointState m_state;
9933e1d4 1178 AccessPointState m_prevState;
8715a84c 1179
8fe90adb
VK
1180 virtual void fillMessageInternal(NXCPMessage *pMsg);
1181 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
1182
ebb2dc70
VK
1183 virtual void updatePingData();
1184
8715a84c
VK
1185public:
1186 AccessPoint();
ac58ffe9 1187 AccessPoint(const TCHAR *name, UINT32 index, const BYTE *macAddr);
8715a84c
VK
1188 virtual ~AccessPoint();
1189
de4af576 1190 virtual int getObjectClass() const { return OBJECT_ACCESSPOINT; }
8715a84c 1191
9bd1bace 1192 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
c42b4551
VK
1193 virtual BOOL saveToDatabase(DB_HANDLE hdb);
1194 virtual bool deleteFromDatabase(DB_HANDLE hdb);
8715a84c 1195
ac58ffe9 1196 void statusPoll(ClientSession *session, UINT32 rqId, Queue *eventQueue, Node *controller, SNMP_Transport *snmpTransport);
56d5289b 1197
ac58ffe9
VK
1198 UINT32 getIndex() { return m_index; }
1199 const BYTE *getMacAddr() { return m_macAddr; }
c30c0c0f 1200 const InetAddress& getIpAddress() { return m_ipAddress; }
f1989a3a 1201 bool isMyRadio(int rfIndex);
386f88e3 1202 bool isMyRadio(const BYTE *macAddr);
f1989a3a 1203 void getRadioName(int rfIndex, TCHAR *buffer, size_t bufSize);
23ed00c4 1204 AccessPointState getState() { return m_state; }
75ebb063 1205 Node *getParentNode();
8715a84c 1206
967893bb 1207 void attachToNode(UINT32 nodeId);
c30c0c0f 1208 void setIpAddress(const InetAddress& addr) { lockProperties(); m_ipAddress = addr; setModified(); unlockProperties(); }
ac58ffe9 1209 void updateRadioInterfaces(const ObjectArray<RadioInterfaceInfo> *ri);
f1989a3a 1210 void updateInfo(const TCHAR *vendor, const TCHAR *model, const TCHAR *serialNumber);
23ed00c4 1211 void updateState(AccessPointState state);
8715a84c
VK
1212};
1213
7de1151b
VK
1214/**
1215 * Cluster class
1216 */
1217class NXCORE_EXPORTABLE Cluster : public DataCollectionTarget
1218{
1219protected:
967893bb 1220 UINT32 m_dwClusterType;
c75e9ee4 1221 ObjectArray<InetAddress> *m_syncNetworks;
967893bb 1222 UINT32 m_dwNumResources;
7de1151b 1223 CLUSTER_RESOURCE *m_pResourceList;
fcfb317c
VK
1224 time_t m_lastStatusPoll;
1225 time_t m_lastConfigurationPoll;
967893bb 1226 UINT32 m_zoneId;
7de1151b 1227
8fe90adb
VK
1228 virtual void fillMessageInternal(NXCPMessage *pMsg);
1229 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
1230
9cac1330
VK
1231 virtual void onDataCollectionChange();
1232
d0089532
VK
1233 UINT32 getResourceOwnerInternal(UINT32 id, const TCHAR *name);
1234
7de1151b
VK
1235public:
1236 Cluster();
967893bb 1237 Cluster(const TCHAR *pszName, UINT32 zoneId);
7de1151b
VK
1238 virtual ~Cluster();
1239
de4af576 1240 virtual int getObjectClass() const { return OBJECT_CLUSTER; }
c42b4551
VK
1241 virtual BOOL saveToDatabase(DB_HANDLE hdb);
1242 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 1243 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
908a59c5 1244 virtual bool showThresholdSummary();
7de1151b 1245
d140955e 1246 virtual void unbindFromTemplate(UINT32 dwTemplateId, bool removeDCI);
0c97b51c 1247
297a88eb
VK
1248 virtual NXSL_Value *createNXSLObject();
1249
c75e9ee4
VK
1250 bool isSyncAddr(const InetAddress& addr);
1251 bool isVirtualAddr(const InetAddress& addr);
967893bb 1252 bool isResourceOnNode(UINT32 dwResource, UINT32 dwNode);
d0089532
VK
1253 UINT32 getResourceOwner(UINT32 resourceId) { return getResourceOwnerInternal(resourceId, NULL); }
1254 UINT32 getResourceOwner(const TCHAR *resourceName) { return getResourceOwnerInternal(0, resourceName); }
967893bb 1255 UINT32 getZoneId() { return m_zoneId; }
7de1151b 1256
208d7427
VK
1257 void statusPoll(PollerInfo *poller);
1258 void statusPoll(ClientSession *pSession, UINT32 dwRqId, PollerInfo *poller);
487cde95 1259 void lockForStatusPoll() { m_flags |= CLF_QUEUED_FOR_STATUS_POLL; }
3f39fdc2 1260 bool isReadyForStatusPoll()
7de1151b 1261 {
db091a1f 1262 return ((m_status != STATUS_UNMANAGED) && (!m_isDeleted) &&
487cde95 1263 (!(m_flags & CLF_QUEUED_FOR_STATUS_POLL)) &&
fcfb317c
VK
1264 ((UINT32)time(NULL) - (UINT32)m_lastStatusPoll > g_dwStatusPollingInterval))
1265 ? true : false;
1266 }
1267
1268 void configurationPoll(PollerInfo *poller);
1269 void configurationPoll(ClientSession *pSession, UINT32 dwRqId, PollerInfo *poller);
1270 void lockForConfigurationPoll() { m_flags |= CLF_QUEUED_FOR_CONFIGURATION_POLL; }
1271 bool isReadyForConfigurationPoll()
1272 {
1273 return ((m_status != STATUS_UNMANAGED) && (!m_isDeleted) &&
1274 (!(m_flags & CLF_QUEUED_FOR_CONFIGURATION_POLL)) &&
1275 ((UINT32)time(NULL) - (UINT32)m_lastConfigurationPoll > g_dwConfigurationPollingInterval))
7de1151b
VK
1276 ? true : false;
1277 }
85ae39bc 1278
967893bb 1279 UINT32 collectAggregatedData(DCItem *item, TCHAR *buffer);
a0ddfb29 1280 UINT32 collectAggregatedData(DCTable *table, Table **result);
d0089532
VK
1281
1282 NXSL_Array *getNodesForNXSL();
7de1151b
VK
1283};
1284
e4926628
VK
1285/**
1286 * Chassis (represents physical chassis)
1287 */
1288class NXCORE_EXPORTABLE Chassis : public DataCollectionTarget
1289{
1290protected:
1291 UINT32 m_controllerId;
1292 INT16 m_rackHeight;
1293 INT16 m_rackPosition;
1294 UINT32 m_rackId;
1295 uuid m_rackImage;
1296
1297 virtual void fillMessageInternal(NXCPMessage *msg);
1298 virtual UINT32 modifyFromMessageInternal(NXCPMessage *request);
1299
1300 virtual void onDataCollectionChange();
46e2b370 1301 virtual void collectProxyInfo(ProxyInfo *info);
e4926628
VK
1302
1303 void updateRackBinding();
32a400d9 1304 void updateControllerBinding();
e4926628
VK
1305
1306public:
1307 Chassis();
1308 Chassis(const TCHAR *name, UINT32 controllerId);
1309 virtual ~Chassis();
1310
1311 virtual int getObjectClass() const { return OBJECT_CHASSIS; }
1312 virtual BOOL saveToDatabase(DB_HANDLE hdb);
1313 virtual bool deleteFromDatabase(DB_HANDLE hdb);
1314 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
32a400d9 1315 virtual void linkObjects();
e4926628 1316 virtual bool showThresholdSummary();
46e2b370 1317 virtual UINT32 getEffectiveSourceNode(DCObject *dco);
e4926628
VK
1318
1319 virtual NXSL_Value *createNXSLObject();
1320
1321 UINT32 getControllerId() const { return m_controllerId; }
1322 UINT32 getRackId() const { return m_rackId; }
1323 INT16 getRackHeight() const { return m_rackHeight; }
1324 INT16 getRackPosition() const { return m_rackPosition; }
32a400d9
VK
1325 bool bindUnderController() { return (m_flags & CHF_BIND_UNDER_CONTROLLER) ? true : false; }
1326
1327 void setBindUnderController(bool doBind);
e4926628
VK
1328};
1329
a85fa05e 1330class Subnet;
9fe7775e 1331struct ProxyInfo;
a85fa05e 1332
e980db40
VK
1333/**
1334 * Node subtypes
1335 */
1336enum NodeType
1337{
1338 NODE_TYPE_UNKNOWN = 0,
1339 NODE_TYPE_PHYSICAL = 1,
1340 NODE_TYPE_VIRTUAL = 2,
1341 NODE_TYPE_CONTROLLER = 3
1342};
1343
9674aefa
VK
1344/**
1345 * Node agent compression modes
1346 */
1347enum NodeAgentCompressionMode
1348{
1349 NODE_AGENT_COMPRESSION_DEFAULT = 0,
1350 NODE_AGENT_COMPRESSION_ENABLED = 1,
1351 NODE_AGENT_COMPRESSION_DISABLED = 2
1352};
1353
f4b2ebd3
VK
1354/**
1355 * Routing loop event information
1356 */
1357class RoutingLoopEvent
1358{
1359private:
1360 InetAddress m_address;
1361 UINT32 m_nodeId;
1362 UINT64 m_eventId;
1363
1364public:
1365 RoutingLoopEvent(const InetAddress& address, UINT32 nodeId, UINT64 eventId)
1366 {
1367 m_address = address;
1368 m_nodeId = nodeId;
1369 m_eventId = eventId;
1370 }
1371
1372 const InetAddress& getAddress() const { return m_address; }
1373 UINT32 getNodeId() const { return m_nodeId; }
1374 UINT64 getEventId() const { return m_eventId; }
1375};
1376
84880c89
VK
1377/**
1378 * Node
1379 */
6fd6de0a 1380class NXCORE_EXPORTABLE Node : public DataCollectionTarget
5039dede 1381{
84880c89
VK
1382 friend class Subnet;
1383
e20d1c43 1384private:
a416f8f6
VK
1385 /**
1386 * Delete agent connection
1387 */
1388 void deleteAgentConnection()
1389 {
83191808 1390 if (m_agentConnection != NULL)
a416f8f6 1391 {
83191808
VK
1392 m_agentConnection->decRefCount();
1393 m_agentConnection = NULL;
a416f8f6
VK
1394 }
1395 }
1396
1397 void onSnmpProxyChange(UINT32 oldProxy);
e20d1c43 1398
a7333ab5 1399 static void onDataCollectionChangeAsyncCallback(void *arg);
9f52bab4 1400
5039dede 1401protected:
c30c0c0f 1402 InetAddress m_ipAddress;
5ad2167d 1403 TCHAR m_primaryName[MAX_DNS_NAME];
0837f989 1404 uuid m_tunnelId;
967893bb 1405 UINT32 m_dwDynamicFlags; // Flags used at runtime by server
e980db40
VK
1406 NodeType m_type;
1407 TCHAR m_subType[MAX_NODE_SUBTYPE_LENGTH];
5039dede
AK
1408 int m_iPendingStatus;
1409 int m_iPollCount;
1410 int m_iRequiredPollCount;
967893bb 1411 UINT32 m_zoneId;
c42b4551 1412 UINT16 m_agentPort;
9708eff4
VK
1413 INT16 m_agentAuthMethod;
1414 INT16 m_agentCacheMode;
9674aefa 1415 INT16 m_agentCompressionMode; // agent compression mode (enabled/disabled/default)
35f836fe 1416 TCHAR m_szSharedSecret[MAX_SECRET_LENGTH];
9708eff4
VK
1417 INT16 m_iStatusPollType;
1418 INT16 m_snmpVersion;
296ae03d 1419 UINT16 m_snmpPort;
9708eff4 1420 UINT16 m_nUseIfXTable;
5d2c5741 1421 SNMP_SecurityContext *m_snmpSecurity;
35f836fe
VK
1422 TCHAR m_szObjectId[MAX_OID_LEN * 4];
1423 TCHAR m_szAgentVersion[MAX_AGENT_VERSION_LEN];
1424 TCHAR m_szPlatformName[MAX_PLATFORM_NAME_LEN];
0ecc2200
VK
1425 TCHAR *m_sysDescription; // Agent's System.Uname or SNMP sysDescr
1426 TCHAR *m_sysName; // SNMP sysName
cf38357f
VK
1427 TCHAR *m_sysLocation; // SNMP sysLocation
1428 TCHAR *m_sysContact; // SNMP sysContact
0ecc2200 1429 TCHAR *m_lldpNodeId; // lldpLocChassisId combined with lldpLocChassisIdSubtype, or NULL for non-LLDP nodes
3a82d5ae 1430 ObjectArray<LLDP_LOCAL_PORT_INFO> *m_lldpLocalPortInfo;
9796ce45 1431 NetworkDeviceDriver *m_driver;
225b92bc 1432 DriverData *m_driverData;
86c126f5
VK
1433 ObjectArray<AgentParameterDefinition> *m_paramList; // List of supported parameters
1434 ObjectArray<AgentTableDefinition> *m_tableList; // List of supported tables
8573e935
VK
1435 time_t m_lastDiscoveryPoll;
1436 time_t m_lastStatusPoll;
1437 time_t m_lastConfigurationPoll;
805171de 1438 time_t m_lastInstancePoll;
8573e935
VK
1439 time_t m_lastTopologyPoll;
1440 time_t m_lastRTUpdate;
1441 time_t m_failTimeSNMP;
1442 time_t m_failTimeAgent;
1443 time_t m_downSince;
71e4ed3a 1444 time_t m_bootTime;
0ab347c0 1445 time_t m_agentUpTime;
4e3133ee 1446 time_t m_lastAgentCommTime;
a01c2a20 1447 time_t m_lastAgentConnectAttempt;
5039dede
AK
1448 MUTEX m_hPollerMutex;
1449 MUTEX m_hAgentAccessMutex;
1d0d82b3 1450 MUTEX m_hSmclpAccessMutex;
5039dede
AK
1451 MUTEX m_mutexRTAccess;
1452 MUTEX m_mutexTopoAccess;
83191808
VK
1453 MUTEX m_snmpProxyConnectionLock;
1454 AgentConnectionEx *m_agentConnection;
1455 AgentConnectionEx *m_snmpProxyConnection;
1d0d82b3 1456 SMCLP_Connection *m_smclpConnection;
685508a7
VK
1457 UINT64 m_lastAgentTrapId; // ID of last received agent trap
1458 UINT64 m_lastAgentPushRequestId; // ID of last received agent push request
489b117b 1459 UINT32 m_lastSNMPTrapId;
685508a7 1460 UINT64 m_lastSyslogMessageId; // ID of last received syslog message
9208c84b
VK
1461 UINT32 m_pollerNode; // Node used for network service polling
1462 UINT32 m_agentProxy; // Node used as proxy for agent connection
1463 UINT32 m_snmpProxy; // Node used as proxy for SNMP requests
1464 UINT32 m_icmpProxy; // Node used as proxy for ICMP ping
f4b2ebd3
VK
1465 UINT64 m_lastEvents[MAX_LAST_EVENTS];
1466 ObjectArray<RoutingLoopEvent> *m_routingLoopEvents;
5039dede 1467 ROUTING_TABLE *m_pRoutingTable;
630e15d6 1468 ForwardingDatabase *m_fdb;
040c45fa 1469 LinkLayerNeighbors *m_linkLayerNeighbors;
7f632dfe 1470 VlanList *m_vlans;
0d75ea88 1471 VrrpInfo *m_vrrpInfo;
d5de1d1d 1472 ObjectArray<WirelessStationInfo> *m_wirelessStations;
f1989a3a
VK
1473 int m_adoptedApCount;
1474 int m_totalApCount;
3eab63f2 1475 BYTE m_baseBridgeAddress[MAC_ADDR_LENGTH]; // Bridge base address (dot1dBaseBridgeAddress in bridge MIB)
3cd8c93a 1476 NetworkMapObjectList *m_topology;
040c45fa 1477 time_t m_topologyRebuildTimestamp;
ab621f39 1478 ServerJobQueue *m_jobQueue;
8836184f 1479 ComponentTree *m_components; // Hardware components
caa04e26 1480 ObjectArray<SoftwarePackage> *m_softwarePackages; // installed software packages
46ee6286 1481 ObjectArray<WinPerfObject> *m_winPerfObjects; // Windows performance objects
e13420c1 1482 AgentConnection *m_fileUpdateConn;
de674bb6
VK
1483 INT16 m_rackHeight;
1484 INT16 m_rackPosition;
1485 UINT32 m_rackId;
1486 uuid m_rackImage;
e4926628 1487 UINT32 m_chassisId;
ba756b1a
VK
1488 INT64 m_syslogMessageCount;
1489 INT64 m_snmpTrapCount;
241541f4
VK
1490 TCHAR m_sshLogin[MAX_SSH_LOGIN_LEN];
1491 TCHAR m_sshPassword[MAX_SSH_PASSWORD_LEN];
1492 UINT32 m_sshProxy;
191137b2
VK
1493 UINT32 m_portNumberingScheme;
1494 UINT32 m_portRowCount;
5039dede 1495
c17f6cbc 1496 void pollerLock() { MutexLock(m_hPollerMutex); }
7c521895 1497 void pollerUnlock() { MutexUnlock(m_hPollerMutex); }
5039dede 1498
c17f6cbc 1499 void agentLock() { MutexLock(m_hAgentAccessMutex); }
7c521895 1500 void agentUnlock() { MutexUnlock(m_hAgentAccessMutex); }
5039dede 1501
1d0d82b3
VK
1502 void smclpLock() { MutexLock(m_hSmclpAccessMutex); }
1503 void smclpUnlock() { MutexUnlock(m_hSmclpAccessMutex); }
1504
c17f6cbc 1505 void routingTableLock() { MutexLock(m_mutexRTAccess); }
7c521895 1506 void routingTableUnlock() { MutexUnlock(m_mutexRTAccess); }
5039dede 1507
074498ac
VK
1508 BOOL checkSNMPIntegerValue(SNMP_Transport *pTransport, const TCHAR *pszOID, int nValue);
1509 void checkOSPFSupport(SNMP_Transport *pTransport);
98762401 1510 void addVrrpInterfaces(InterfaceList *ifList);
024c3faf 1511 BOOL resolveName(BOOL useOnlyDNS);
c75e9ee4 1512 void setPrimaryIPAddress(const InetAddress& addr);
5039dede 1513
ed83ffcd 1514 bool setAgentProxy(AgentConnectionEx *conn);
9674aefa
VK
1515 bool isAgentCompressionAllowed();
1516
967893bb 1517 UINT32 getInterfaceCount(Interface **ppInterface);
5039dede 1518
024c3faf 1519 void checkInterfaceNames(InterfaceList *pIfList);
e55ff6f9 1520 bool filterInterface(InterfaceInfo *info);
64478dc4 1521 Subnet *createSubnet(InetAddress& baseAddr, bool syntheticMask);
1f385e47 1522 void checkAgentPolicyBinding(AgentConnection *conn);
5a7d6a10 1523 void updatePrimaryIpAddr();
967893bb
VK
1524 bool confPollAgent(UINT32 dwRqId);
1525 bool confPollSnmp(UINT32 dwRqId);
e980db40 1526 NodeType detectNodeType();
cf38357f 1527 bool querySnmpSysProperty(SNMP_Transport *snmp, const TCHAR *oid, const TCHAR *propName, UINT32 pollRqId, TCHAR **value);
76720a09
VK
1528 void checkBridgeMib(SNMP_Transport *pTransport);
1529 void checkIfXTable(SNMP_Transport *pTransport);
1824629a 1530 void executeHookScript(const TCHAR *hookName);
a7b1e779
VK
1531 bool checkNetworkPath(UINT32 requestId);
1532 bool checkNetworkPathLayer2(UINT32 requestId, bool secondPass);
1533 bool checkNetworkPathLayer3(UINT32 requestId, bool secondPass);
1534 bool checkNetworkPathElement(UINT32 nodeId, const TCHAR *nodeType, bool isProxy, UINT32 requestId, bool secondPass);
5039dede 1535
f7e3eb5a 1536 void doInstanceDiscovery(UINT32 requestId);
e9c75749
EJ
1537 StringMap *getInstanceList(DCObject *dco);
1538 bool updateInstances(DCObject *root, StringMap *instances, UINT32 requestId);
a7333ab5 1539 void syncDataCollectionWithAgent(AgentConnectionEx *conn);
4262c0dc 1540
dfed892b 1541 bool updateInterfaceConfiguration(UINT32 rqid, int maskBits);
e13420c1 1542 bool deleteDuplicateInterfaces(UINT32 rqid);
e4926628 1543 void updatePhysicalContainerBinding(int containerClass, UINT32 containerId);
c4e4d666
VK
1544
1545 bool connectToAgent(UINT32 *error = NULL, UINT32 *socketError = NULL, bool *newConnection = NULL, bool forceConnect = false);
6f77fadd 1546 void setLastAgentCommTime() { time_t now = time(NULL); if (m_lastAgentCommTime < now - 60) { m_lastAgentCommTime = now; setModified(); } }
4262c0dc 1547
3cd8c93a 1548 void buildIPTopologyInternal(NetworkMapObjectList &topology, int nDepth, UINT32 seedObject, bool vpnLink, bool includeEndNodes);
84880c89 1549
6fd6de0a 1550 virtual bool isDataCollectionDisabled();
46e2b370 1551 virtual void collectProxyInfo(ProxyInfo *info);
6fd6de0a 1552
22ee6d97 1553 virtual void prepareForDeletion();
967893bb 1554 virtual void onObjectDelete(UINT32 dwObjectId);
5039dede 1555
8fe90adb
VK
1556 virtual void fillMessageInternal(NXCPMessage *pMsg);
1557 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
1558
ebb2dc70
VK
1559 virtual void updatePingData();
1560
9fd816cc
VK
1561 virtual void onDataCollectionChange();
1562
5039dede
AK
1563public:
1564 Node();
de4c3060 1565 Node(const InetAddress& addr, UINT32 dwFlags, UINT32 agentProxy, UINT32 snmpProxy, UINT32 icmpProxy, UINT32 sshProxy, UINT32 zoneId);
5039dede
AK
1566 virtual ~Node();
1567
de4af576 1568 virtual int getObjectClass() const { return OBJECT_NODE; }
5039dede 1569
c42b4551
VK
1570 virtual BOOL saveToDatabase(DB_HANDLE hdb);
1571 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 1572 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
5039dede 1573
297a88eb
VK
1574 virtual NXSL_Value *createNXSLObject();
1575
df1aac85 1576 TCHAR *expandText(const TCHAR *textTemplate, StringMap *inputFields, const TCHAR *userName);
6e388680 1577
7c521895 1578 Cluster *getMyCluster();
5039dede 1579
46e2b370
VK
1580 const InetAddress& getIpAddress() const { return m_ipAddress; }
1581 UINT32 getZoneId() const { return m_zoneId; }
e980db40
VK
1582 NodeType getType() const { return m_type; }
1583 const TCHAR *getSubType() const { return m_subType; }
46e2b370 1584 UINT32 getRuntimeFlags() const { return m_dwDynamicFlags; }
60b3a756 1585
487cde95
VK
1586 void setFlag(UINT32 flag) { lockProperties(); m_flags |= flag; setModified(); unlockProperties(); }
1587 void clearFlag(UINT32 flag) { lockProperties(); m_flags &= ~flag; setModified(); unlockProperties(); }
1588 void setLocalMgmtFlag() { m_flags |= NF_IS_LOCAL_MGMT; }
1589 void clearLocalMgmtFlag() { m_flags &= ~NF_IS_LOCAL_MGMT; }
5039dede 1590
60b3a756
VK
1591 void setType(NodeType type, const TCHAR *subType) { lockProperties(); m_type = type; nx_strncpy(m_subType, subType, MAX_NODE_SUBTYPE_LENGTH); unlockProperties(); }
1592
487cde95
VK
1593 bool isSNMPSupported() const { return m_flags & NF_IS_SNMP ? true : false; }
1594 bool isNativeAgent() const { return m_flags & NF_IS_NATIVE_AGENT ? true : false; }
1595 bool isBridge() const { return m_flags & NF_IS_BRIDGE ? true : false; }
1596 bool isRouter() const { return m_flags & NF_IS_ROUTER ? true : false; }
1597 bool isLocalManagement() const { return m_flags & NF_IS_LOCAL_MGMT ? true : false; }
46e2b370 1598 bool isPerVlanFdbSupported() const { return (m_driver != NULL) ? m_driver->isPerVlanFdbSupported() : false; }
487cde95 1599 bool isWirelessController() const { return m_flags & NF_IS_WIFI_CONTROLLER ? true : false; }
5039dede 1600
e961f4e9 1601 INT16 getSNMPVersion() const { return m_snmpVersion; }
46e2b370 1602 UINT16 getSNMPPort() const { return m_snmpPort; }
e4926628
VK
1603 const TCHAR *getSNMPObjectId() const { return m_szObjectId; }
1604 const TCHAR *getAgentVersion() const { return m_szAgentVersion; }
1605 const TCHAR *getPlatformName() const { return m_szPlatformName; }
1606 const TCHAR *getObjectId() const { return m_szObjectId; }
1607 const TCHAR *getSysName() const { return CHECK_NULL_EX(m_sysName); }
1608 const TCHAR *getSysDescription() const { return CHECK_NULL_EX(m_sysDescription); }
1609 const TCHAR *getSysContact() const { return CHECK_NULL_EX(m_sysContact); }
1610 const TCHAR *getSysLocation() const { return CHECK_NULL_EX(m_sysLocation); }
1611 time_t getBootTime() const { return m_bootTime; }
1612 const TCHAR *getLLDPNodeId() const { return m_lldpNodeId; }
1613 const BYTE *getBridgeId() const { return m_baseBridgeAddress; }
1614 const TCHAR *getDriverName() const { return (m_driver != NULL) ? m_driver->getName() : _T("GENERIC"); }
1615 UINT16 getAgentPort() const { return m_agentPort; }
1616 INT16 getAgentAuthMethod() const { return m_agentAuthMethod; }
1617 INT16 getAgentCacheMode() const { return (m_dwDynamicFlags & NDF_CACHE_MODE_NOT_SUPPORTED) ? AGENT_CACHE_OFF : ((m_agentCacheMode == AGENT_CACHE_DEFAULT) ? g_defaultAgentCacheMode : m_agentCacheMode); }
1618 const TCHAR *getSharedSecret() const { return m_szSharedSecret; }
1619 UINT32 getRackId() const { return m_rackId; }
1620 INT16 getRackHeight() const { return m_rackHeight; }
1621 INT16 getRackPosition() const { return m_rackPosition; }
46e2b370
VK
1622 bool hasFileUpdateConnection() const { lockProperties(); bool result = (m_fileUpdateConn != NULL); unlockProperties(); return result; }
1623 UINT32 getIcmpProxy() const { return m_icmpProxy; }
241541f4
VK
1624 const TCHAR *getSshLogin() const { return m_sshLogin; }
1625 const TCHAR *getSshPassword() const { return m_sshPassword; }
1626 UINT32 getSshProxy() const { return m_sshProxy; }
489e7869 1627 time_t getLastAgentCommTime() const { return m_lastAgentCommTime; }
f1984eb9 1628 const TCHAR *getPrimaryName() const { return m_primaryName; }
0837f989 1629 const uuid& getTunnelId() const { return m_tunnelId; }
5039dede 1630
0717a453 1631 bool isDown() { return (m_dwDynamicFlags & NDF_UNREACHABLE) ? true : false; }
8573e935 1632 time_t getDownTime() const { return m_downSince; }
5039dede 1633
1f8be1f4 1634 void addInterface(Interface *pInterface) { addChild(pInterface); pInterface->addParent(this); }
c77bdd19
VK
1635 Interface *createNewInterface(InterfaceInfo *ifInfo, bool manuallyCreated, bool fakeInterface);
1636 Interface *createNewInterface(const InetAddress& ipAddr, BYTE *macAddr, bool fakeInterface);
c30c0c0f 1637 void deleteInterface(Interface *iface);
5039dede 1638
5a7d6a10 1639 void setPrimaryName(const TCHAR *name) { nx_strncpy(m_primaryName, name, MAX_DNS_NAME); }
de4c3060
VK
1640 void setAgentPort(UINT16 port) { m_agentPort = port; }
1641 void setSnmpPort(UINT16 port) { m_snmpPort = port; }
1642 void setSshCredentials(const TCHAR *login, const TCHAR *password);
c75e9ee4 1643 void changeIPAddress(const InetAddress& ipAddr);
967893bb 1644 void changeZone(UINT32 newZone);
0837f989 1645 void setTunnelId(const uuid& tunnelId);
f9f79a93 1646 void setFileUpdateConnection(AgentConnection *conn);
4b535d78 1647 void clearDataCollectionConfigFromAgent(AgentConnectionEx *conn);
46e2b370
VK
1648 void forceSyncDataCollectionConfig();
1649 void relatedNodeDataCollectionChanged() { onDataCollectionChange(); }
5039dede 1650
7c521895 1651 ARP_CACHE *getArpCache();
98762401 1652 InterfaceList *getInterfaceList();
c75e9ee4
VK
1653 Interface *findInterfaceByIndex(UINT32 ifIndex);
1654 Interface *findInterfaceByName(const TCHAR *name);
eec253a8 1655 Interface *findInterfaceByMAC(const BYTE *macAddr);
c75e9ee4 1656 Interface *findInterfaceByIP(const InetAddress& addr);
967893bb
VK
1657 Interface *findInterfaceBySlotAndPort(UINT32 slot, UINT32 port);
1658 Interface *findBridgePort(UINT32 bridgePortNumber);
8f26db67 1659 AccessPoint *findAccessPointByMAC(const BYTE *macAddr);
386f88e3 1660 AccessPoint *findAccessPointByBSSID(const BYTE *bssid);
8f26db67 1661 AccessPoint *findAccessPointByRadioId(int rfIndex);
75ebb063 1662 ObjectArray<WirelessStationInfo> *getWirelessStations();
c75e9ee4 1663 bool isMyIP(const InetAddress& addr);
3d37f7bf 1664 void getInterfaceStatusFromSNMP(SNMP_Transport *pTransport, UINT32 dwIndex, int ifTableSuffixLen, UINT32 *ifTableSuffix, InterfaceAdminState *adminState, InterfaceOperState *operState);
42c6d15b 1665 void getInterfaceStatusFromAgent(UINT32 dwIndex, InterfaceAdminState *adminState, InterfaceOperState *operState);
58b3e451
VK
1666 ROUTING_TABLE *getRoutingTable();
1667 ROUTING_TABLE *getCachedRoutingTable() { return m_pRoutingTable; }
a9ad9f61 1668 LinkLayerNeighbors *getLinkLayerNeighbors();
7f632dfe 1669 VlanList *getVlans();
f4b2ebd3 1670 bool getNextHop(const InetAddress& srcAddr, const InetAddress& destAddr, InetAddress *nextHop, InetAddress *route, UINT32 *ifIndex, bool *isVpn, TCHAR *name);
c75e9ee4 1671 bool getOutwardInterface(const InetAddress& destAddr, InetAddress *srcAddr, UINT32 *srcIfIndex);
8836184f 1672 ComponentTree *getComponents();
fe58ae54 1673 bool getLldpLocalPortInfo(UINT32 idType, BYTE *id, size_t idLen, LLDP_LOCAL_PORT_INFO *port);
cf1d689e 1674 void showLLDPInfo(CONSOLE_CTX console);
5039dede 1675
58b3e451 1676 void setRecheckCapsFlag() { m_dwDynamicFlags |= NDF_RECHECK_CAPABILITIES; }
7c521895 1677 void setDiscoveryPollTimeStamp();
208d7427
VK
1678 void statusPoll(ClientSession *pSession, UINT32 dwRqId, PollerInfo *poller);
1679 void statusPoll(PollerInfo *poller);
1680 void configurationPoll(PollerInfo *poller);
1681 void configurationPoll(ClientSession *pSession, UINT32 dwRqId, PollerInfo *poller, int maskBits);
1682 void instanceDiscoveryPoll(PollerInfo *poller);
1683 void instanceDiscoveryPoll(ClientSession *session, UINT32 requestId, PollerInfo *poller);
1684 void topologyPoll(PollerInfo *poller);
1685 void topologyPoll(ClientSession *pSession, UINT32 dwRqId, PollerInfo *poller);
b1bd1fb2 1686 void resolveVlanPorts(VlanList *vlanList);
967893bb 1687 void updateInterfaceNames(ClientSession *pSession, UINT32 dwRqId);
208d7427 1688 void routingTablePoll(PollerInfo *poller);
58b3e451 1689 void updateRoutingTable();
c30c0c0f 1690 void checkSubnetBinding();
ac58ffe9 1691 AccessPointState getAccessPointState(AccessPoint *ap, SNMP_Transport *snmpTransport);
1c1e431e 1692 void setChassis(UINT32 chassisId);
72e97d1c 1693
7c521895
VK
1694 bool isReadyForStatusPoll();
1695 bool isReadyForConfigurationPoll();
805171de 1696 bool isReadyForInstancePoll();
7c521895
VK
1697 bool isReadyForDiscoveryPoll();
1698 bool isReadyForRoutePoll();
040c45fa 1699 bool isReadyForTopologyPoll();
0ab347c0 1700
7c521895
VK
1701 void lockForStatusPoll();
1702 void lockForConfigurationPoll();
805171de 1703 void lockForInstancePoll();
7c521895
VK
1704 void lockForDiscoveryPoll();
1705 void lockForRoutePoll();
040c45fa 1706 void lockForTopologyPoll();
7c521895 1707 void forceConfigurationPoll() { m_dwDynamicFlags |= NDF_FORCE_CONFIGURATION_POLL; }
5039dede 1708
27f9598d 1709 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
5039dede 1710
6fbaa926 1711 bool checkAgentTrapId(UINT64 id);
489b117b 1712 bool checkSNMPTrapId(UINT32 id);
685508a7 1713 bool checkSyslogMessageId(UINT64 id);
6fbaa926 1714 bool checkAgentPushRequestId(UINT64 id);
6fd6de0a 1715
1d0d82b3
VK
1716 bool connectToSMCLP();
1717
17b1ab4a
VK
1718 virtual UINT32 getInternalItem(const TCHAR *param, size_t bufSize, TCHAR *buffer);
1719
1720 UINT32 getItemFromSNMP(WORD port, const TCHAR *param, size_t bufSize, TCHAR *buffer, int interpretRawValue);
db117859 1721 UINT32 getTableFromSNMP(WORD port, const TCHAR *oid, ObjectArray<DCTableColumn> *columns, Table **table);
967893bb 1722 UINT32 getListFromSNMP(WORD port, const TCHAR *oid, StringList **list);
69a4eaa6 1723 UINT32 getOIDSuffixListFromSNMP(WORD port, const TCHAR *oid, StringMap **values);
967893bb
VK
1724 UINT32 getItemFromCheckPointSNMP(const TCHAR *szParam, UINT32 dwBufSize, TCHAR *szBuffer);
1725 UINT32 getItemFromAgent(const TCHAR *szParam, UINT32 dwBufSize, TCHAR *szBuffer);
1726 UINT32 getTableFromAgent(const TCHAR *name, Table **table);
1727 UINT32 getListFromAgent(const TCHAR *name, StringList **list);
1728 UINT32 getItemForClient(int iOrigin, const TCHAR *pszParam, TCHAR *pszBuffer, UINT32 dwBufSize);
1729 UINT32 getTableForClient(const TCHAR *name, Table **table);
1730 UINT32 getItemFromSMCLP(const TCHAR *param, UINT32 bufSize, TCHAR *buffer);
6fd6de0a 1731
06c104c6 1732 virtual NXSL_Array *getParentsForNXSL();
0ae82278 1733 virtual NXSL_Array *getTemplatesForNXSL();
6adc4a1a 1734 NXSL_Array *getInterfacesForNXSL();
5039dede 1735
86c126f5 1736 void openParamList(ObjectArray<AgentParameterDefinition> **paramList);
c42b4551 1737 void closeParamList() { unlockProperties(); }
5039dede 1738
86c126f5 1739 void openTableList(ObjectArray<AgentTableDefinition> **tableList);
c42b4551 1740 void closeTableList() { unlockProperties(); }
074498ac 1741
7f6ecb6d 1742 AgentConnectionEx *createAgentConnection(bool sendServerId = false);
83191808 1743 AgentConnectionEx *acquireSnmpProxyConnection();
072e4643 1744 SNMP_Transport *createSnmpTransport(WORD port = 0, const TCHAR *context = NULL);
46e2b370
VK
1745 SNMP_SecurityContext *getSnmpSecurityContext() const;
1746 UINT32 getEffectiveSnmpProxy() const;
5039dede 1747
b368969c
VK
1748 void writeParamListToMessage(NXCPMessage *pMsg, WORD flags);
1749 void writeWinPerfObjectsToMessage(NXCPMessage *msg);
1750 void writePackageListToMessage(NXCPMessage *msg);
1751 void writeWsListToMessage(NXCPMessage *msg);
5039dede 1752
967893bb 1753 UINT32 wakeUp();
5039dede 1754
1f8be1f4 1755 void addService(NetworkService *pNetSrv) { addChild(pNetSrv); pNetSrv->addParent(this); }
c75e9ee4 1756 UINT32 checkNetworkService(UINT32 *pdwStatus, const InetAddress& ipAddr, int iServiceType, WORD wPort = 0,
b8014eee 1757 WORD wProto = 0, TCHAR *pszRequest = NULL, TCHAR *pszResponse = NULL, UINT32 *responseTime = NULL);
5039dede 1758
f4b2ebd3
VK
1759 UINT64 getLastEventId(int index) { return ((index >= 0) && (index < MAX_LAST_EVENTS)) ? m_lastEvents[index] : 0; }
1760 void setLastEventId(int index, UINT64 eventId) { if ((index >= 0) && (index < MAX_LAST_EVENTS)) m_lastEvents[index] = eventId; }
1761 void setRoutingLoopEvent(const InetAddress& address, UINT32 nodeId, UINT64 eventId);
5039dede 1762
3f39fdc2 1763 UINT32 callSnmpEnumerate(const TCHAR *pszRootOid,
9c5ebc32 1764 UINT32 (* pHandler)(SNMP_Variable *, SNMP_Transport *, void *), void *pArg, const TCHAR *context = NULL);
5039dede 1765
3cd8c93a
VK
1766 NetworkMapObjectList *getL2Topology();
1767 NetworkMapObjectList *buildL2Topology(UINT32 *pdwStatus, int radius, bool includeEndNodes);
630e15d6 1768 ForwardingDatabase *getSwitchForwardingDatabase();
75ebb063 1769 NetObj *findConnectionPoint(UINT32 *localIfId, BYTE *localMacAddr, int *type);
33ae8896 1770 void addHostConnections(LinkLayerNeighbors *nbs);
0003c4ba 1771 void addExistingConnections(LinkLayerNeighbors *nbs);
ab621f39 1772
3cd8c93a 1773 NetworkMapObjectList *buildIPTopology(UINT32 *pdwStatus, int radius, bool includeEndNodes);
84880c89 1774
ab621f39 1775 ServerJobQueue *getJobQueue() { return m_jobQueue; }
0ff10010 1776 int getJobCount(const TCHAR *type = NULL) { return m_jobQueue->getJobCount(type); }
5039dede 1777
225b92bc
VK
1778 DriverData *getDriverData() { return m_driverData; }
1779 void setDriverData(DriverData *data) { m_driverData = data; }
ba756b1a
VK
1780
1781 void incSyslogMessageCount();
1782 void incSnmpTrapCount();
e980db40
VK
1783
1784 static const TCHAR *typeName(NodeType type);
6a665011 1785};
5039dede 1786
6a665011
VK
1787/**
1788 * Set timestamp of last discovery poll to current time
1789 */
7c521895 1790inline void Node::setDiscoveryPollTimeStamp()
5039dede 1791{
8573e935 1792 m_lastDiscoveryPoll = time(NULL);
5039dede
AK
1793 m_dwDynamicFlags &= ~NDF_QUEUED_FOR_DISCOVERY_POLL;
1794}
1795
3f39fdc2 1796inline bool Node::isReadyForStatusPoll()
5039dede 1797{
01152a54 1798 if (m_isDeleted)
7c521895 1799 return false;
5039dede
AK
1800 if (m_dwDynamicFlags & NDF_FORCE_STATUS_POLL)
1801 {
1802 m_dwDynamicFlags &= ~NDF_FORCE_STATUS_POLL;
7c521895 1803 return true;
5039dede 1804 }
db091a1f 1805 return (m_status != STATUS_UNMANAGED) &&
487cde95 1806 (!(m_flags & NF_DISABLE_STATUS_POLL)) &&
7c521895
VK
1807 (!(m_dwDynamicFlags & NDF_QUEUED_FOR_STATUS_POLL)) &&
1808 (!(m_dwDynamicFlags & NDF_POLLING_DISABLED)) &&
1809 (getMyCluster() == NULL) &&
805171de 1810 ((UINT32)(time(NULL) - m_lastStatusPoll) > g_dwStatusPollingInterval);
5039dede
AK
1811}
1812
3f39fdc2 1813inline bool Node::isReadyForConfigurationPoll()
1814{
01152a54 1815 if (m_isDeleted)
7c521895 1816 return false;
5039dede
AK
1817 if (m_dwDynamicFlags & NDF_FORCE_CONFIGURATION_POLL)
1818 {
1819 m_dwDynamicFlags &= ~NDF_FORCE_CONFIGURATION_POLL;
7c521895 1820 return true;
5039dede 1821 }
db091a1f 1822 return (m_status != STATUS_UNMANAGED) &&
487cde95 1823 (!(m_flags & NF_DISABLE_CONF_POLL)) &&
7c521895
VK
1824 (!(m_dwDynamicFlags & NDF_QUEUED_FOR_CONFIG_POLL)) &&
1825 (!(m_dwDynamicFlags & NDF_POLLING_DISABLED)) &&
805171de 1826 ((UINT32)(time(NULL) - m_lastConfigurationPoll) > g_dwConfigurationPollingInterval);
5039dede
AK
1827}
1828
3f39fdc2 1829inline bool Node::isReadyForDiscoveryPoll()
1830{
01152a54 1831 if (m_isDeleted)
7c521895 1832 return false;
c8076b19 1833 return (g_flags & AF_ENABLE_NETWORK_DISCOVERY) &&
db091a1f 1834 (m_status != STATUS_UNMANAGED) &&
487cde95 1835 (!(m_flags & NF_DISABLE_DISCOVERY_POLL)) &&
7c521895
VK
1836 (!(m_dwDynamicFlags & NDF_QUEUED_FOR_DISCOVERY_POLL)) &&
1837 (!(m_dwDynamicFlags & NDF_POLLING_DISABLED)) &&
1838 (m_dwDynamicFlags & NDF_CONFIGURATION_POLL_PASSED) &&
805171de 1839 ((UINT32)(time(NULL) - m_lastDiscoveryPoll) > g_dwDiscoveryPollingInterval);
5039dede
AK
1840}
1841
3f39fdc2 1842inline bool Node::isReadyForRoutePoll()
1843{
01152a54 1844 if (m_isDeleted)
7c521895 1845 return false;
db091a1f 1846 return (m_status != STATUS_UNMANAGED) &&
487cde95 1847 (!(m_flags & NF_DISABLE_ROUTE_POLL)) &&
7c521895
VK
1848 (!(m_dwDynamicFlags & NDF_QUEUED_FOR_ROUTE_POLL)) &&
1849 (!(m_dwDynamicFlags & NDF_POLLING_DISABLED)) &&
b6ead716 1850 (m_dwDynamicFlags & NDF_CONFIGURATION_POLL_PASSED) &&
805171de 1851 ((UINT32)(time(NULL) - m_lastRTUpdate) > g_dwRoutingTableUpdateInterval);
5039dede
AK
1852}
1853
3f39fdc2 1854inline bool Node::isReadyForTopologyPoll()
1855{
01152a54 1856 if (m_isDeleted)
040c45fa 1857 return false;
db091a1f 1858 return (m_status != STATUS_UNMANAGED) &&
487cde95 1859 (!(m_flags & NF_DISABLE_TOPOLOGY_POLL)) &&
040c45fa
VK
1860 (!(m_dwDynamicFlags & NDF_QUEUED_FOR_TOPOLOGY_POLL)) &&
1861 (!(m_dwDynamicFlags & NDF_POLLING_DISABLED)) &&
b6ead716 1862 (m_dwDynamicFlags & NDF_CONFIGURATION_POLL_PASSED) &&
805171de
VK
1863 ((UINT32)(time(NULL) - m_lastTopologyPoll) > g_dwTopologyPollingInterval);
1864}
1865
1866inline bool Node::isReadyForInstancePoll()
1867{
1868 if (m_isDeleted)
1869 return false;
db091a1f 1870 return (m_status != STATUS_UNMANAGED) &&
487cde95 1871 (!(m_flags & NF_DISABLE_CONF_POLL)) &&
805171de
VK
1872 (!(m_dwDynamicFlags & NDF_QUEUED_FOR_INSTANCE_POLL)) &&
1873 (!(m_dwDynamicFlags & NDF_POLLING_DISABLED)) &&
1874 (m_dwDynamicFlags & NDF_CONFIGURATION_POLL_PASSED) &&
1875 ((UINT32)(time(NULL) - m_lastInstancePoll) > g_instancePollingInterval);
040c45fa
VK
1876}
1877
7c521895 1878inline void Node::lockForStatusPoll()
3f39fdc2 1879{
c42b4551 1880 lockProperties();
3f39fdc2 1881 m_dwDynamicFlags |= NDF_QUEUED_FOR_STATUS_POLL;
c42b4551 1882 unlockProperties();
5039dede
AK
1883}
1884
3f39fdc2 1885inline void Node::lockForConfigurationPoll()
1886{
c42b4551 1887 lockProperties();
3f39fdc2 1888 m_dwDynamicFlags |= NDF_QUEUED_FOR_CONFIG_POLL;
c42b4551 1889 unlockProperties();
5039dede
AK
1890}
1891
805171de
VK
1892inline void Node::lockForInstancePoll()
1893{
1894 lockProperties();
1895 m_dwDynamicFlags |= NDF_QUEUED_FOR_INSTANCE_POLL;
1896 unlockProperties();
1897}
1898
3f39fdc2 1899inline void Node::lockForDiscoveryPoll()
1900{
c42b4551 1901 lockProperties();
3f39fdc2 1902 m_dwDynamicFlags |= NDF_QUEUED_FOR_DISCOVERY_POLL;
c42b4551 1903 unlockProperties();
5039dede
AK
1904}
1905
3f39fdc2 1906inline void Node::lockForTopologyPoll()
1907{
c42b4551 1908 lockProperties();
3f39fdc2 1909 m_dwDynamicFlags |= NDF_QUEUED_FOR_TOPOLOGY_POLL;
c42b4551 1910 unlockProperties();
040c45fa
VK
1911}
1912
3f39fdc2 1913inline void Node::lockForRoutePoll()
1914{
c42b4551 1915 lockProperties();
3f39fdc2 1916 m_dwDynamicFlags |= NDF_QUEUED_FOR_ROUTE_POLL;
c42b4551 1917 unlockProperties();
5039dede
AK
1918}
1919
84880c89
VK
1920/**
1921 * Subnet
1922 */
5039dede
AK
1923class NXCORE_EXPORTABLE Subnet : public NetObj
1924{
3cd8c93a 1925 friend void Node::buildIPTopologyInternal(NetworkMapObjectList &topology, int nDepth, UINT32 seedSubnet, bool vpnLink, bool includeEndNodes);
84880c89 1926
5039dede 1927protected:
c30c0c0f 1928 InetAddress m_ipAddress;
967893bb 1929 UINT32 m_zoneId;
eec253a8 1930 bool m_bSyntheticMask;
5039dede 1931
ce47611c
VK
1932 virtual void prepareForDeletion();
1933
8fe90adb
VK
1934 virtual void fillMessageInternal(NXCPMessage *pMsg);
1935
3cd8c93a 1936 void buildIPTopologyInternal(NetworkMapObjectList &topology, int nDepth, UINT32 seedNode, bool includeEndNodes);
84880c89 1937
5039dede
AK
1938public:
1939 Subnet();
c75e9ee4 1940 Subnet(const InetAddress& addr, UINT32 dwZone, bool bSyntheticMask);
5039dede
AK
1941 virtual ~Subnet();
1942
de4af576 1943 virtual int getObjectClass() const { return OBJECT_SUBNET; }
5039dede 1944
c42b4551
VK
1945 virtual BOOL saveToDatabase(DB_HANDLE hdb);
1946 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 1947 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
5039dede 1948
1f8be1f4 1949 void addNode(Node *node) { addChild(node); node->addParent(this); calculateCompoundStatus(TRUE); }
5039dede 1950
27bbb906
VK
1951 virtual bool showThresholdSummary();
1952
c30c0c0f 1953 const InetAddress& getIpAddress() { return m_ipAddress; }
967893bb 1954 UINT32 getZoneId() { return m_zoneId; }
eec253a8 1955 bool isSyntheticMask() { return m_bSyntheticMask; }
5039dede 1956
c75e9ee4 1957 void setCorrectMask(const InetAddress& addr);
80e0db05 1958
c75e9ee4 1959 bool findMacAddress(const InetAddress& ipAddr, BYTE *macAddr);
ceb0fc8d
VK
1960
1961 UINT32 *buildAddressMap(int *length);
5039dede
AK
1962};
1963
84880c89
VK
1964/**
1965 * Universal root object
1966 */
5039dede
AK
1967class NXCORE_EXPORTABLE UniversalRoot : public NetObj
1968{
2c1e391c
VK
1969 using NetObj::loadFromDatabase;
1970
5039dede
AK
1971public:
1972 UniversalRoot();
1973 virtual ~UniversalRoot();
1974
c42b4551 1975 virtual BOOL saveToDatabase(DB_HANDLE hdb);
9bd1bace 1976 void loadFromDatabase(DB_HANDLE hdb);
32a400d9 1977 virtual void linkObjects();
1f8be1f4 1978 void linkObject(NetObj *pObject) { addChild(pObject); pObject->addParent(this); }
5039dede
AK
1979};
1980
826fcc1f
VK
1981/**
1982 * Service root
1983 */
5039dede
AK
1984class NXCORE_EXPORTABLE ServiceRoot : public UniversalRoot
1985{
1986public:
1987 ServiceRoot();
1988 virtual ~ServiceRoot();
1989
de4af576 1990 virtual int getObjectClass() const { return OBJECT_SERVICEROOT; }
27bbb906
VK
1991
1992 virtual bool showThresholdSummary();
5039dede
AK
1993};
1994
826fcc1f
VK
1995/**
1996 * Template root
1997 */
5039dede
AK
1998class NXCORE_EXPORTABLE TemplateRoot : public UniversalRoot
1999{
2000public:
2001 TemplateRoot();
2002 virtual ~TemplateRoot();
2003
de4af576 2004 virtual int getObjectClass() const { return OBJECT_TEMPLATEROOT; }
27f9598d 2005 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
5039dede
AK
2006};
2007
27bbb906
VK
2008/**
2009 * Generic container object
2010 */
5039dede
AK
2011class NXCORE_EXPORTABLE Container : public NetObj
2012{
2013private:
967893bb
VK
2014 UINT32 *m_pdwChildIdList;
2015 UINT32 m_dwChildIdListSize;
5039dede
AK
2016
2017protected:
967893bb 2018 UINT32 m_flags;
9fc9ec2c 2019 NXSL_Program *m_bindFilter;
4262c0dc 2020 TCHAR *m_bindFilterSource;
5039dede 2021
23464115
VK
2022 virtual void fillMessageInternal(NXCPMessage *msg);
2023 virtual UINT32 modifyFromMessageInternal(NXCPMessage *request);
8fe90adb 2024
034e2615
VK
2025 void setAutoBindFilterInternal(const TCHAR *script);
2026
5039dede
AK
2027public:
2028 Container();
967893bb 2029 Container(const TCHAR *pszName, UINT32 dwCategory);
5039dede
AK
2030 virtual ~Container();
2031
de4af576 2032 virtual int getObjectClass() const { return OBJECT_CONTAINER; }
3f39fdc2 2033
c42b4551
VK
2034 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2035 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 2036 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
32a400d9 2037 virtual void linkObjects();
5039dede 2038
27bbb906
VK
2039 virtual bool showThresholdSummary();
2040
4547feec
VK
2041 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
2042
034e2615
VK
2043 virtual NXSL_Value *createNXSLObject();
2044
1f8be1f4 2045 void linkObject(NetObj *pObject) { addChild(pObject); pObject->addParent(this); }
4262c0dc 2046
fcfb317c 2047 AutoBindDecision isSuitableForObject(NetObj *object);
034e2615
VK
2048 bool isAutoBindEnabled() const { return (m_flags & CF_AUTO_BIND) ? true : false; }
2049 bool isAutoUnbindEnabled() const { return ((m_flags & (CF_AUTO_BIND | CF_AUTO_UNBIND)) == (CF_AUTO_BIND | CF_AUTO_UNBIND)) ? true : false; }
2050 const TCHAR *getAutoBindScriptSource() const { return m_bindFilterSource; }
15c5bcbf 2051
034e2615
VK
2052 void setAutoBindFilter(const TCHAR *script) { lockProperties(); setAutoBindFilterInternal(script); unlockProperties(); }
2053 void setAutoBindMode(bool doBind, bool doUnbind);
5039dede
AK
2054};
2055
27bbb906
VK
2056/**
2057 * Template group object
2058 */
5039dede
AK
2059class NXCORE_EXPORTABLE TemplateGroup : public Container
2060{
2061public:
2062 TemplateGroup() : Container() { }
db091a1f 2063 TemplateGroup(const TCHAR *pszName) : Container(pszName, 0) { m_status = STATUS_NORMAL; }
5039dede
AK
2064 virtual ~TemplateGroup() { }
2065
de4af576 2066 virtual int getObjectClass() const { return OBJECT_TEMPLATEGROUP; }
27f9598d 2067 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
5039dede 2068
27bbb906
VK
2069 virtual bool showThresholdSummary();
2070};
5039dede 2071
8715a84c
VK
2072/**
2073 * Rack object
2074 */
2075class NXCORE_EXPORTABLE Rack : public Container
2076{
2077protected:
2078 int m_height; // Rack height in units
b120cd0f 2079 bool m_topBottomNumbering;
8715a84c 2080
8fe90adb
VK
2081 virtual void fillMessageInternal(NXCPMessage *pMsg);
2082 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2083
8715a84c
VK
2084public:
2085 Rack();
2086 Rack(const TCHAR *name, int height);
2087 virtual ~Rack();
2088
de4af576 2089 virtual int getObjectClass() const { return OBJECT_RACK; }
8715a84c 2090
c42b4551
VK
2091 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2092 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 2093 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
8715a84c
VK
2094};
2095
27bbb906
VK
2096/**
2097 * Zone object
2098 */
5039dede
AK
2099class Zone : public NetObj
2100{
2101protected:
967893bb 2102 UINT32 m_zoneId;
43b62436 2103 UINT32 m_proxyNodeId;
c75e9ee4
VK
2104 InetAddressIndex *m_idxNodeByAddr;
2105 InetAddressIndex *m_idxInterfaceByAddr;
2106 InetAddressIndex *m_idxSubnetByAddr;
5039dede 2107
241541f4
VK
2108 virtual void fillMessageInternal(NXCPMessage *msg);
2109 virtual UINT32 modifyFromMessageInternal(NXCPMessage *request);
8fe90adb 2110
5039dede
AK
2111public:
2112 Zone();
967893bb 2113 Zone(UINT32 zoneId, const TCHAR *name);
5039dede
AK
2114 virtual ~Zone();
2115
de4af576 2116 virtual int getObjectClass() const { return OBJECT_ZONE; }
5039dede 2117
c42b4551
VK
2118 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2119 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 2120 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
5039dede 2121
27bbb906
VK
2122 virtual bool showThresholdSummary();
2123
297a88eb
VK
2124 virtual NXSL_Value *createNXSLObject();
2125
241541f4 2126 UINT32 getZoneId() const { return m_zoneId; }
43b62436 2127 UINT32 getProxyNodeId() const { return m_proxyNodeId; }
5039dede 2128
1f8be1f4 2129 void addSubnet(Subnet *pSubnet) { addChild(pSubnet); pSubnet->addParent(this); }
5e39b8a3 2130
c75e9ee4 2131 void addToIndex(Subnet *subnet) { m_idxSubnetByAddr->put(subnet->getIpAddress(), subnet); }
c30c0c0f 2132 void addToIndex(Interface *iface) { m_idxInterfaceByAddr->put(iface->getIpAddressList(), iface); }
5f6e8d09 2133 void addToIndex(const InetAddress& addr, Interface *iface) { m_idxInterfaceByAddr->put(addr, iface); }
c75e9ee4
VK
2134 void addToIndex(Node *node) { m_idxNodeByAddr->put(node->getIpAddress(), node); }
2135 void removeFromIndex(Subnet *subnet) { m_idxSubnetByAddr->remove(subnet->getIpAddress()); }
c30c0c0f 2136 void removeFromIndex(Interface *iface);
5f6e8d09 2137 void removeFromInterfaceIndex(const InetAddress& addr) { m_idxInterfaceByAddr->remove(addr); }
c75e9ee4
VK
2138 void removeFromIndex(Node *node) { m_idxNodeByAddr->remove(node->getIpAddress()); }
2139 void updateInterfaceIndex(const InetAddress& oldIp, const InetAddress& newIp, Interface *iface);
2140 Subnet *getSubnetByAddr(const InetAddress& ipAddr) { return (Subnet *)m_idxSubnetByAddr->get(ipAddr); }
2141 Interface *getInterfaceByAddr(const InetAddress& ipAddr) { return (Interface *)m_idxInterfaceByAddr->get(ipAddr); }
2142 Node *getNodeByAddr(const InetAddress& ipAddr) { return (Node *)m_idxNodeByAddr->get(ipAddr); }
89135050
VK
2143 Subnet *findSubnet(bool (*comparator)(NetObj *, void *), void *data) { return (Subnet *)m_idxSubnetByAddr->find(comparator, data); }
2144 Interface *findInterface(bool (*comparator)(NetObj *, void *), void *data) { return (Interface *)m_idxInterfaceByAddr->find(comparator, data); }
16d6f798 2145 Node *findNode(bool (*comparator)(NetObj *, void *), void *data) { return (Node *)m_idxNodeByAddr->find(comparator, data); }
c30c0c0f 2146 void forEachSubnet(void (*callback)(const InetAddress& addr, NetObj *, void *), void *data) { m_idxSubnetByAddr->forEach(callback, data); }
0dd7953d 2147 ObjectArray<NetObj> *getSubnets(bool updateRefCount) { return m_idxSubnetByAddr->getObjects(updateRefCount); }
a1286d8b
VK
2148 void dumpInterfaceIndex(CONSOLE_CTX console);
2149 void dumpNodeIndex(CONSOLE_CTX console);
2150 void dumpSubnetIndex(CONSOLE_CTX console);
5039dede
AK
2151};
2152
27bbb906
VK
2153/**
2154 * Entire network
2155 */
5039dede
AK
2156class NXCORE_EXPORTABLE Network : public NetObj
2157{
2c1e391c
VK
2158 using NetObj::loadFromDatabase;
2159
5039dede
AK
2160public:
2161 Network();
2162 virtual ~Network();
2163
de4af576 2164 virtual int getObjectClass() const { return OBJECT_NETWORK; }
c42b4551 2165 virtual BOOL saveToDatabase(DB_HANDLE hdb);
5039dede 2166
27bbb906
VK
2167 virtual bool showThresholdSummary();
2168
1f8be1f4
VK
2169 void AddSubnet(Subnet *pSubnet) { addChild(pSubnet); pSubnet->addParent(this); }
2170 void AddZone(Zone *pZone) { addChild(pZone); pZone->addParent(this); }
9bd1bace 2171 void loadFromDatabase(DB_HANDLE hdb);
5039dede
AK
2172};
2173
27bbb906
VK
2174/**
2175 * Condition
2176 */
9f06d008 2177class NXCORE_EXPORTABLE ConditionObject : public NetObj
5039dede
AK
2178{
2179protected:
9fddfb91
VK
2180 UINT32 m_dciCount;
2181 INPUT_DCI *m_dciList;
2182 TCHAR *m_scriptSource;
6b29839d 2183 NXSL_VM *m_script;
9fddfb91
VK
2184 UINT32 m_activationEventCode;
2185 UINT32 m_deactivationEventCode;
2186 UINT32 m_sourceObject;
2187 int m_activeStatus;
2188 int m_inactiveStatus;
2189 bool m_isActive;
2190 time_t m_lastPoll;
2191 bool m_queuedForPolling;
5039dede 2192
8fe90adb
VK
2193 virtual void fillMessageInternal(NXCPMessage *pMsg);
2194 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2195
5039dede 2196public:
9f06d008
VK
2197 ConditionObject();
2198 ConditionObject(bool hidden);
2199 virtual ~ConditionObject();
5039dede 2200
de4af576 2201 virtual int getObjectClass() const { return OBJECT_CONDITION; }
5039dede 2202
c42b4551
VK
2203 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2204 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 2205 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
5039dede 2206
9fddfb91 2207 void lockForPoll();
208d7427
VK
2208 void doPoll(PollerInfo *poller);
2209 void check();
5039dede 2210
9fddfb91 2211 bool isReadyForPoll()
5039dede 2212 {
db091a1f 2213 return ((m_status != STATUS_UNMANAGED) &&
9fddfb91
VK
2214 (!m_queuedForPolling) && (!m_isDeleted) &&
2215 ((UINT32)time(NULL) - (UINT32)m_lastPoll > g_dwConditionPollingInterval));
5039dede
AK
2216 }
2217
9fddfb91 2218 int getCacheSizeForDCI(UINT32 itemId, bool noLock);
5039dede
AK
2219};
2220
27bbb906
VK
2221/**
2222 * Generic agent policy object
2223 */
a6d66d3a
VK
2224class NXCORE_EXPORTABLE AgentPolicy : public NetObj
2225{
2226protected:
967893bb 2227 UINT32 m_version;
a6d66d3a 2228 int m_policyType;
a6d66d3a 2229
3f7c0fe4 2230 BOOL savePolicyCommonProperties(DB_HANDLE hdb);
45d84f8a 2231
8fe90adb
VK
2232 virtual void fillMessageInternal(NXCPMessage *pMsg);
2233 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2234
a6d66d3a
VK
2235public:
2236 AgentPolicy(int type);
45d84f8a 2237 AgentPolicy(const TCHAR *name, int type);
6e53f004 2238
de4af576 2239 virtual int getObjectClass() const { return OBJECT_AGENTPOLICY; }
6e53f004 2240
c42b4551
VK
2241 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2242 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 2243 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
6e53f004 2244
b368969c
VK
2245 virtual bool createDeploymentMessage(NXCPMessage *msg);
2246 virtual bool createUninstallMessage(NXCPMessage *msg);
93599cfd 2247
1f8be1f4
VK
2248 void linkNode(Node *node) { addChild(node); node->addParent(this); }
2249 void unlinkNode(Node *node) { deleteChild(node); node->deleteParent(this); }
a6d66d3a
VK
2250};
2251
27bbb906
VK
2252/**
2253 * Agent config policy object
2254 */
f2bb4aa1
VK
2255class NXCORE_EXPORTABLE AgentPolicyConfig : public AgentPolicy
2256{
2257protected:
f2bb4aa1
VK
2258 TCHAR *m_fileContent;
2259
8fe90adb
VK
2260 virtual void fillMessageInternal(NXCPMessage *pMsg);
2261 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2262
f2bb4aa1
VK
2263public:
2264 AgentPolicyConfig();
45d84f8a 2265 AgentPolicyConfig(const TCHAR *name);
f2bb4aa1
VK
2266 virtual ~AgentPolicyConfig();
2267
de4af576 2268 virtual int getObjectClass() const { return OBJECT_AGENTPOLICY_CONFIG; }
f2bb4aa1 2269
c42b4551
VK
2270 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2271 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 2272 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
f2bb4aa1 2273
b368969c
VK
2274 virtual bool createDeploymentMessage(NXCPMessage *msg);
2275 virtual bool createUninstallMessage(NXCPMessage *msg);
f2bb4aa1
VK
2276};
2277
3df8bccd
Z
2278/**
2279 * Log parser configuration policy object
2280 */
2281class NXCORE_EXPORTABLE AgentPolicyLogParser : public AgentPolicy
2282{
2283 protected:
2284 TCHAR *m_fileContent;
2285
2286 virtual void fillMessageInternal(NXCPMessage *pMsg);
2287 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2288 public:
2289 AgentPolicyLogParser();
2290 AgentPolicyLogParser(const TCHAR *name);
2291 virtual ~AgentPolicyLogParser();
2292
2293 virtual int getObjectClass() const { return OBJECT_AGENTPOLICY_LOGPARSER; }
2294
2295 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2296 virtual bool deleteFromDatabase(DB_HANDLE hdb);
2297 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
2298
2299 virtual bool createDeploymentMessage(NXCPMessage *msg);
2300 virtual bool createUninstallMessage(NXCPMessage *msg);
2301};
2302
27bbb906
VK
2303/**
2304 * Policy group object
2305 */
a6d66d3a
VK
2306class NXCORE_EXPORTABLE PolicyGroup : public Container
2307{
2308public:
2309 PolicyGroup() : Container() { }
27f9598d 2310 PolicyGroup(const TCHAR *pszName) : Container(pszName, 0) { }
a6d66d3a
VK
2311 virtual ~PolicyGroup() { }
2312
de4af576 2313 virtual int getObjectClass() const { return OBJECT_POLICYGROUP; }
27f9598d 2314 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
a6d66d3a 2315
27bbb906
VK
2316 virtual bool showThresholdSummary();
2317};
a6d66d3a 2318
27bbb906
VK
2319/**
2320 * Policy root
2321 */
a6d66d3a
VK
2322class NXCORE_EXPORTABLE PolicyRoot : public UniversalRoot
2323{
2324public:
2325 PolicyRoot();
2326 virtual ~PolicyRoot();
2327
de4af576 2328 virtual int getObjectClass() const { return OBJECT_POLICYROOT; }
27f9598d 2329 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
a6d66d3a
VK
2330};
2331
27bbb906
VK
2332/**
2333 * Network map root
2334 */
021dcda7
VK
2335class NXCORE_EXPORTABLE NetworkMapRoot : public UniversalRoot
2336{
2337public:
2338 NetworkMapRoot();
2339 virtual ~NetworkMapRoot();
2340
de4af576 2341 virtual int getObjectClass() const { return OBJECT_NETWORKMAPROOT; }
27f9598d 2342 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
021dcda7
VK
2343};
2344
27bbb906
VK
2345/**
2346 * Network map group object
2347 */
021dcda7
VK
2348class NXCORE_EXPORTABLE NetworkMapGroup : public Container
2349{
2350public:
2351 NetworkMapGroup() : Container() { }
27f9598d 2352 NetworkMapGroup(const TCHAR *pszName) : Container(pszName, 0) { }
021dcda7
VK
2353 virtual ~NetworkMapGroup() { }
2354
de4af576 2355 virtual int getObjectClass() const { return OBJECT_NETWORKMAPGROUP; }
27f9598d 2356 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
021dcda7 2357
27bbb906
VK
2358 virtual bool showThresholdSummary();
2359};
021dcda7 2360
27bbb906
VK
2361/**
2362 * Network map object
2363 */
021dcda7
VK
2364class NXCORE_EXPORTABLE NetworkMap : public NetObj
2365{
2366protected:
2367 int m_mapType;
3e883888 2368 IntegerArray<UINT32> *m_seedObjects;
84880c89 2369 int m_discoveryRadius;
021dcda7 2370 int m_layout;
967893bb 2371 UINT32 m_flags;
e4acd770 2372 int m_backgroundColor;
291247b2 2373 int m_defaultLinkColor;
e4acd770 2374 int m_defaultLinkRouting;
7a8aa001 2375 int m_objectDisplayMode;
de4af576 2376 uuid m_background;
1a74dc37
VK
2377 double m_backgroundLatitude;
2378 double m_backgroundLongitude;
2379 int m_backgroundZoom;
967893bb 2380 UINT32 m_nextElementId;
dba7a1a8
VK
2381 ObjectArray<NetworkMapElement> *m_elements;
2382 ObjectArray<NetworkMapLink> *m_links;
701726bc 2383 TCHAR *m_filterSource;
6b29839d 2384 NXSL_VM *m_filter;
dba7a1a8 2385
8fe90adb
VK
2386 virtual void fillMessageInternal(NXCPMessage *pMsg);
2387 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2388
3cd8c93a 2389 void updateObjects(NetworkMapObjectList *objects);
967893bb
VK
2390 UINT32 objectIdFromElementId(UINT32 eid);
2391 UINT32 elementIdFromObjectId(UINT32 eid);
ef3ebcdf 2392
89ec7c82
VK
2393 void setFilter(const TCHAR *filter);
2394
021dcda7
VK
2395public:
2396 NetworkMap();
3e883888 2397 NetworkMap(int type, IntegerArray<UINT32> *seeds);
021dcda7
VK
2398 virtual ~NetworkMap();
2399
de4af576 2400 virtual int getObjectClass() const { return OBJECT_NETWORKMAP; }
27f9598d 2401 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
021dcda7 2402
c42b4551
VK
2403 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2404 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 2405 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
021dcda7 2406
4af351c7
VK
2407 virtual void onObjectDelete(UINT32 dwObjectId);
2408
2409 void updateContent();
5a883bb7
VK
2410
2411 int getBackgroundColor() { return m_backgroundColor; }
2412 void setBackgroundColor(int color) { m_backgroundColor = color; }
701726bc 2413
701726bc 2414 bool isAllowedOnMap(NetObj *object);
021dcda7
VK
2415};
2416
27bbb906
VK
2417/**
2418 * Dashboard tree root
2419 */
27f9598d
VK
2420class NXCORE_EXPORTABLE DashboardRoot : public UniversalRoot
2421{
2422public:
2423 DashboardRoot();
2424 virtual ~DashboardRoot();
2425
de4af576 2426 virtual int getObjectClass() const { return OBJECT_DASHBOARDROOT; }
27f9598d
VK
2427 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
2428};
2429
27bbb906
VK
2430/**
2431 * Dashboard element
2432 */
27f9598d
VK
2433class DashboardElement
2434{
2435public:
2436 int m_type;
2437 TCHAR *m_data;
fceea457 2438 TCHAR *m_layout;
27f9598d 2439
fceea457
VK
2440 DashboardElement() { m_data = NULL; m_layout = NULL; }
2441 ~DashboardElement() { safe_free(m_data); safe_free(m_layout); }
27f9598d
VK
2442};
2443
27bbb906
VK
2444/**
2445 * Dashboard object
2446 */
27f9598d
VK
2447class NXCORE_EXPORTABLE Dashboard : public Container
2448{
2449protected:
2450 int m_numColumns;
967893bb 2451 UINT32 m_options;
27f9598d
VK
2452 ObjectArray<DashboardElement> *m_elements;
2453
8fe90adb
VK
2454 virtual void fillMessageInternal(NXCPMessage *pMsg);
2455 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2456
27f9598d
VK
2457public:
2458 Dashboard();
2459 Dashboard(const TCHAR *name);
2460 virtual ~Dashboard();
2461
de4af576 2462 virtual int getObjectClass() const { return OBJECT_DASHBOARD; }
27f9598d 2463 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
926e8ce7 2464
c42b4551
VK
2465 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2466 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 2467 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
926e8ce7 2468
27bbb906
VK
2469 virtual bool showThresholdSummary();
2470};
27f9598d 2471
27bbb906
VK
2472/**
2473 * SLM check object
2474 */
fc958888
AK
2475class NXCORE_EXPORTABLE SlmCheck : public NetObj
2476{
2477protected:
140b8ada
VK
2478 static NXSL_VariableSystem m_nxslConstants;
2479
1621a079 2480 Threshold *m_threshold;
fc958888 2481 enum CheckType { check_undefined = 0, check_script = 1, check_threshold = 2 } m_type;
1621a079 2482 TCHAR *m_script;
6b29839d 2483 NXSL_VM *m_pCompiledScript;
1621a079 2484 TCHAR m_reason[256];
63c1ae35 2485 bool m_isTemplate;
967893bb
VK
2486 UINT32 m_templateId;
2487 UINT32 m_currentTicketId;
1621a079 2488
967893bb 2489 virtual void onObjectDelete(UINT32 objectId);
6ff21d27 2490
8fe90adb
VK
2491 virtual void fillMessageInternal(NXCPMessage *pMsg);
2492 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2493
2494 void setScript(const TCHAR *script);
967893bb 2495 UINT32 getOwnerId();
eb3d3e10 2496 NXSL_Value *getNodeObjectForNXSL();
636e0c72
VK
2497 bool insertTicket();
2498 void closeTicket();
2499 void setReason(const TCHAR *reason) { nx_strncpy(m_reason, CHECK_NULL_EX(reason), 256); }
28207240 2500 void compileScript();
fc958888
AK
2501
2502public:
2503 SlmCheck();
6ff21d27
VK
2504 SlmCheck(const TCHAR *name, bool isTemplate);
2505 SlmCheck(SlmCheck *tmpl);
fc958888
AK
2506 virtual ~SlmCheck();
2507
140b8ada
VK
2508 static void init();
2509
de4af576 2510 virtual int getObjectClass() const { return OBJECT_SLMCHECK; }
fc958888 2511
c42b4551
VK
2512 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2513 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 2514 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
fc958888 2515
6ff21d27 2516 virtual void postModify();
fc958888 2517
ae3d7f46 2518 void execute();
6ff21d27
VK
2519 void updateFromTemplate(SlmCheck *tmpl);
2520
2521 bool isTemplate() { return m_isTemplate; }
967893bb 2522 UINT32 getTemplateId() { return m_templateId; }
1621a079 2523 const TCHAR *getReason() { return m_reason; }
fc958888
AK
2524};
2525
27bbb906
VK
2526/**
2527 * Service container - common logic for BusinessService, NodeLink and BusinessServiceRoot
2528 */
3f39fdc2 2529class NXCORE_EXPORTABLE ServiceContainer : public Container
fc958888 2530{
93d91beb
AK
2531 enum Period { DAY, WEEK, MONTH };
2532
fc958888 2533protected:
1b534360 2534 time_t m_prevUptimeUpdateTime;
1b534360 2535 int m_prevUptimeUpdateStatus;
93d91beb
AK
2536 double m_uptimeDay;
2537 double m_uptimeWeek;
2538 double m_uptimeMonth;
05c9a2f9
VK
2539 INT32 m_downtimeDay;
2540 INT32 m_downtimeWeek;
2541 INT32 m_downtimeMonth;
2542 INT32 m_prevDiffDay;
2543 INT32 m_prevDiffWeek;
2544 INT32 m_prevDiffMonth;
2545
2546 static INT32 logRecordId;
2547 static INT32 getSecondsInMonth();
2548 static INT32 getSecondsInPeriod(Period period) { return period == MONTH ? getSecondsInMonth() : (period == WEEK ? (3600 * 24 * 7) : (3600 * 24)); }
2549 static INT32 getSecondsSinceBeginningOf(Period period, time_t *beginTime = NULL);
93d91beb 2550
8fe90adb
VK
2551 virtual void fillMessageInternal(NXCPMessage *pMsg);
2552 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2553
3e2bf4aa 2554 void initServiceContainer();
93d91beb 2555 BOOL addHistoryRecord();
05c9a2f9 2556 double getUptimeFromDBFor(Period period, INT32 *downtime);
63c1ae35 2557
3e2bf4aa
AK
2558public:
2559 ServiceContainer();
4a1e58e5
VK
2560 ServiceContainer(const TCHAR *pszName);
2561
9bd1bace 2562 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
c42b4551
VK
2563 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2564 virtual bool deleteFromDatabase(DB_HANDLE hdb);
4a1e58e5 2565
3e2bf4aa
AK
2566 virtual void calculateCompoundStatus(BOOL bForcedRecalc = FALSE);
2567 virtual void setStatus(int newStatus);
d4036c05 2568
27bbb906
VK
2569 virtual bool showThresholdSummary();
2570
d4036c05 2571 void initUptimeStats();
f43056c7 2572 void updateUptimeStats(time_t currentTime = 0, BOOL updateChilds = FALSE);
3e2bf4aa
AK
2573};
2574
05c9a2f9
VK
2575/**
2576 * Business service root
2577 */
4a1e58e5 2578class NXCORE_EXPORTABLE BusinessServiceRoot : public ServiceContainer
3e2bf4aa 2579{
2c1e391c
VK
2580 using ServiceContainer::loadFromDatabase;
2581
3e2bf4aa
AK
2582public:
2583 BusinessServiceRoot();
2584 virtual ~BusinessServiceRoot();
2585
de4af576 2586 virtual int getObjectClass() const { return OBJECT_BUSINESSSERVICEROOT; }
4a1e58e5 2587
c42b4551 2588 virtual BOOL saveToDatabase(DB_HANDLE hdb);
9bd1bace 2589 void loadFromDatabase(DB_HANDLE hdb);
4a1e58e5 2590
32a400d9
VK
2591 virtual void linkObjects();
2592
1f8be1f4 2593 void linkObject(NetObj *pObject) { addChild(pObject); pObject->addParent(this); }
3e2bf4aa
AK
2594};
2595
f6cd5b2f
VK
2596/**
2597 * Business service object
2598 */
3e2bf4aa
AK
2599class NXCORE_EXPORTABLE BusinessService : public ServiceContainer
2600{
2601protected:
2602 bool m_busy;
f6cd5b2f 2603 bool m_pollingDisabled;
3e2bf4aa
AK
2604 time_t m_lastPollTime;
2605 int m_lastPollStatus;
2606
f6cd5b2f
VK
2607 virtual void prepareForDeletion();
2608
8fe90adb
VK
2609 virtual void fillMessageInternal(NXCPMessage *pMsg);
2610 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2611
fc958888 2612public:
1621a079
VK
2613 BusinessService();
2614 BusinessService(const TCHAR *name);
2615 virtual ~BusinessService();
fc958888 2616
de4af576 2617 virtual int getObjectClass() const { return OBJECT_BUSINESSSERVICE; }
fc958888 2618
9bd1bace 2619 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
c42b4551
VK
2620 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2621 virtual bool deleteFromDatabase(DB_HANDLE hdb);
fc958888 2622
52c75f5c
AK
2623 bool isReadyForPolling();
2624 void lockForPolling();
208d7427
VK
2625 void poll(PollerInfo *poller);
2626 void poll(ClientSession *pSession, UINT32 dwRqId, PollerInfo *poller);
6ff21d27
VK
2627
2628 void getApplicableTemplates(ServiceContainer *target, ObjectArray<SlmCheck> *templates);
fc958888
AK
2629};
2630
22ee6d97
VK
2631/**
2632 * Node link object for business service
2633 */
3e2bf4aa
AK
2634class NXCORE_EXPORTABLE NodeLink : public ServiceContainer
2635{
2636protected:
967893bb 2637 UINT32 m_nodeId;
3e2bf4aa 2638
967893bb 2639 virtual void onObjectDelete(UINT32 dwObjectId);
c50f77f7 2640
8fe90adb
VK
2641 virtual void fillMessageInternal(NXCPMessage *pMsg);
2642 virtual UINT32 modifyFromMessageInternal(NXCPMessage *pRequest);
2643
6ff21d27
VK
2644 void applyTemplate(SlmCheck *tmpl);
2645
3e2bf4aa
AK
2646public:
2647 NodeLink();
967893bb 2648 NodeLink(const TCHAR *name, UINT32 nodeId);
3e2bf4aa
AK
2649 virtual ~NodeLink();
2650
de4af576 2651 virtual int getObjectClass() const { return OBJECT_NODELINK; }
3e2bf4aa 2652
c42b4551
VK
2653 virtual BOOL saveToDatabase(DB_HANDLE hdb);
2654 virtual bool deleteFromDatabase(DB_HANDLE hdb);
9bd1bace 2655 virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
3e2bf4aa 2656
3e2bf4aa 2657 void execute();
6ff21d27 2658 void applyTemplates();
3e2bf4aa 2659
967893bb 2660 UINT32 getNodeId() { return m_nodeId; }
3e2bf4aa
AK
2661};
2662
c30c0c0f
VK
2663/**
2664 * Get IP address for object
2665 */
2666inline const InetAddress& GetObjectIpAddress(NetObj *object)
2667{
2668 if (object->getObjectClass() == OBJECT_NODE)
2669 return ((Node *)object)->getIpAddress();
2670 if (object->getObjectClass() == OBJECT_SUBNET)
2671 return ((Subnet *)object)->getIpAddress();
2672 if (object->getObjectClass() == OBJECT_ACCESSPOINT)
2673 return ((AccessPoint *)object)->getIpAddress();
ca594353
VK
2674 if (object->getObjectClass() == OBJECT_INTERFACE)
2675 return ((Interface *)object)->getIpAddressList()->getFirstUnicastAddress();
c30c0c0f
VK
2676 return InetAddress::INVALID;
2677}
fc958888 2678
23464115
VK
2679/**
2680 * Functions
2681 */
021dcda7 2682void ObjectsInit();
5039dede 2683
22f38627
VK
2684void NXCORE_EXPORTABLE NetObjInsert(NetObj *object, bool newObject, bool importedObject);
2685void NetObjDeleteFromIndexes(NetObj *object);
2686void NetObjDelete(NetObj *object);
5039dede 2687
c75e9ee4 2688void UpdateInterfaceIndex(const InetAddress& oldIpAddr, const InetAddress& newIpAddr, Interface *iface);
8836184f 2689ComponentTree *BuildComponentTree(Node *node, SNMP_Transport *snmp);
5039dede 2690
edecb8ef
VK
2691void NXCORE_EXPORTABLE MacDbAddAccessPoint(AccessPoint *ap);
2692void NXCORE_EXPORTABLE MacDbAddInterface(Interface *iface);
2693void NXCORE_EXPORTABLE MacDbAddObject(const BYTE *macAddr, NetObj *object);
2694void NXCORE_EXPORTABLE MacDbRemove(const BYTE *macAddr);
2695NetObj NXCORE_EXPORTABLE *MacDbFind(const BYTE *macAddr);
2696
967893bb 2697NetObj NXCORE_EXPORTABLE *FindObjectById(UINT32 dwId, int objClass = -1);
0b75b2c8
VK
2698NetObj NXCORE_EXPORTABLE *FindObjectByName(const TCHAR *name, int objClass = -1);
2699NetObj NXCORE_EXPORTABLE *FindObjectByGUID(const uuid& guid, int objClass = -1);
2700NetObj NXCORE_EXPORTABLE *FindObject(bool (* comparator)(NetObj *, void *), void *userData, int objClass = -1);
fffcff95 2701const TCHAR NXCORE_EXPORTABLE *GetObjectName(DWORD id, const TCHAR *defaultName);
5039dede 2702Template NXCORE_EXPORTABLE *FindTemplateByName(const TCHAR *pszName);
c75e9ee4 2703Node NXCORE_EXPORTABLE *FindNodeByIP(UINT32 zoneId, const InetAddress& ipAddr);
c30c0c0f 2704Node NXCORE_EXPORTABLE *FindNodeByIP(UINT32 zoneId, const InetAddressList *ipAddrList);
06a93345 2705Node NXCORE_EXPORTABLE *FindNodeByMAC(const BYTE *macAddr);
4005181b 2706Node NXCORE_EXPORTABLE *FindNodeByBridgeId(const BYTE *bridgeId);
eec253a8 2707Node NXCORE_EXPORTABLE *FindNodeByLLDPId(const TCHAR *lldpId);
052e15b3 2708Node NXCORE_EXPORTABLE *FindNodeBySysName(const TCHAR *sysName);
f1984eb9 2709ObjectArray<NetObj> *FindNodesByHostname(TCHAR *hostname, UINT32 zoneId);
c75e9ee4 2710Interface NXCORE_EXPORTABLE *FindInterfaceByIP(UINT32 zoneId, const InetAddress& ipAddr);
06a93345 2711Interface NXCORE_EXPORTABLE *FindInterfaceByMAC(const BYTE *macAddr);
478d4ff4 2712Interface NXCORE_EXPORTABLE *FindInterfaceByDescription(const TCHAR *description);
c75e9ee4
VK
2713Subnet NXCORE_EXPORTABLE *FindSubnetByIP(UINT32 zoneId, const InetAddress& ipAddr);
2714Subnet NXCORE_EXPORTABLE *FindSubnetForNode(UINT32 zoneId, const InetAddress& nodeAddr);
534e1b83 2715MobileDevice NXCORE_EXPORTABLE *FindMobileDeviceByDeviceID(const TCHAR *deviceId);
c6afd26a 2716AccessPoint NXCORE_EXPORTABLE *FindAccessPointByMAC(const BYTE *macAddr);
967893bb 2717UINT32 NXCORE_EXPORTABLE FindLocalMgmtNode();
967893bb 2718Zone NXCORE_EXPORTABLE *FindZoneByGUID(UINT32 dwZoneGUID);
c75e9ee4
VK
2719Cluster NXCORE_EXPORTABLE *FindClusterByResourceIP(UINT32 zone, const InetAddress& ipAddr);
2720bool NXCORE_EXPORTABLE IsClusterIP(UINT32 zone, const InetAddress& ipAddr);
1390643d 2721bool NXCORE_EXPORTABLE IsParentObject(UINT32 object1, UINT32 object2);
5039dede 2722
021dcda7 2723BOOL LoadObjects();
01ca557f 2724void DumpObjects(CONSOLE_CTX pCtx, const TCHAR *filter);
5039dede 2725
5eabf181
VK
2726bool NXCORE_EXPORTABLE CreateObjectAccessSnapshot(UINT32 userId, int objClass);
2727
967893bb 2728void DeleteUserFromAllObjects(UINT32 dwUserId);
5039dede 2729
e4926628 2730bool IsValidParentClass(int childClass, int parentClass);
1f385e47 2731bool IsAgentPolicyObject(NetObj *object);
fc381a38 2732bool IsEventSource(int objectClass);
5039dede
AK
2733
2734int DefaultPropagatedStatus(int iObjectStatus);
2735int GetDefaultStatusCalculation(int *pnSingleThreshold, int **ppnThresholds);
2736
208d7427
VK
2737PollerInfo *RegisterPoller(PollerType type, NetObj *object);
2738void ShowPollers(CONSOLE_CTX console);
2739
fc381a38
VK
2740/**
2741 * Global variables
2742 */
fb05c05b
VK
2743extern Network NXCORE_EXPORTABLE *g_pEntireNet;
2744extern ServiceRoot NXCORE_EXPORTABLE *g_pServiceRoot;
2745extern TemplateRoot NXCORE_EXPORTABLE *g_pTemplateRoot;
2746extern PolicyRoot NXCORE_EXPORTABLE *g_pPolicyRoot;
926e8ce7
VK
2747extern NetworkMapRoot NXCORE_EXPORTABLE *g_pMapRoot;
2748extern DashboardRoot NXCORE_EXPORTABLE *g_pDashboardRoot;
1621a079 2749extern BusinessServiceRoot NXCORE_EXPORTABLE *g_pBusinessServiceRoot;
5039dede 2750
967893bb 2751extern UINT32 NXCORE_EXPORTABLE g_dwMgmtNode;
5039dede
AK
2752extern BOOL g_bModificationsLocked;
2753extern Queue *g_pTemplateUpdateQueue;
2754
5f0fc7a9 2755extern ObjectIndex NXCORE_EXPORTABLE g_idxObjectById;
c75e9ee4
VK
2756extern InetAddressIndex NXCORE_EXPORTABLE g_idxSubnetByAddr;
2757extern InetAddressIndex NXCORE_EXPORTABLE g_idxInterfaceByAddr;
2758extern InetAddressIndex NXCORE_EXPORTABLE g_idxNodeByAddr;
5f0fc7a9
VK
2759extern ObjectIndex NXCORE_EXPORTABLE g_idxZoneByGUID;
2760extern ObjectIndex NXCORE_EXPORTABLE g_idxNodeById;
46e2b370 2761extern ObjectIndex NXCORE_EXPORTABLE g_idxChassisById;
85ae39bc 2762extern ObjectIndex NXCORE_EXPORTABLE g_idxClusterById;
9aa67910 2763extern ObjectIndex NXCORE_EXPORTABLE g_idxMobileDeviceById;
c6afd26a 2764extern ObjectIndex NXCORE_EXPORTABLE g_idxAccessPointById;
5f0fc7a9 2765extern ObjectIndex NXCORE_EXPORTABLE g_idxConditionById;
6ff21d27 2766extern ObjectIndex NXCORE_EXPORTABLE g_idxServiceCheckById;
9d605305 2767
5039dede 2768#endif /* _nms_objects_h_ */