- LastValues view improved
[public/netxms.git] / src / server / include / nms_objects.h
1 /*
2 ** NetXMS - Network Management System
3 ** Copyright (C) 2003, 2004, 2005 Victor Kirhenshtein
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 **
19 ** $module: nms_objects.h
20 **
21 **/
22
23 #ifndef _nms_objects_h_
24 #define _nms_objects_h_
25
26 #include <nms_agent.h>
27 #include <nxnt.h>
28
29
30 //
31 // Forward declarations of classes
32 //
33
34 class AgentConnection;
35 class ClientSession;
36 class Queue;
37
38
39 //
40 // Global variables used by inline functions
41 //
42
43 extern DWORD g_dwDiscoveryPollingInterval;
44 extern DWORD g_dwStatusPollingInterval;
45 extern DWORD g_dwConfigurationPollingInterval;
46
47
48 //
49 // Constants
50 //
51
52 #define MAX_INTERFACES 4096
53 #define INVALID_INDEX 0xFFFFFFFF
54
55
56 //
57 // Last events
58 //
59
60 #define MAX_LAST_EVENTS 8
61
62 #define LAST_EVENT_NODE_DOWN 0
63
64
65 //
66 // Discovery flags
67 //
68
69 #define DF_CHECK_INTERFACES 0x0001
70 #define DF_CHECK_ARP 0x0002
71 #define DF_DEFAULT (DF_CHECK_INTERFACES | DF_CHECK_ARP)
72
73
74 //
75 // Node runtime (dynamic) flags
76 //
77
78 #define NDF_QUEUED_FOR_STATUS_POLL 0x0001
79 #define NDF_QUEUED_FOR_CONFIG_POLL 0x0002
80 #define NDF_UNREACHEABLE 0x0004
81
82
83 //
84 // Status poll types
85 //
86
87 #define POLL_ICMP_PING 0
88 #define POLL_SNMP 1
89 #define POLL_NATIVE_AGENT 2
90
91
92 //
93 // Base class for network objects
94 //
95
96 class NXCORE_EXPORTABLE Node;
97
98 class NXCORE_EXPORTABLE NetObj
99 {
100 protected:
101 DWORD m_dwId;
102 DWORD m_dwRefCount; // Number of references. Object can be deleted only when this counter is zero
103 char m_szName[MAX_OBJECT_NAME];
104 int m_iStatus;
105 BOOL m_bIsModified;
106 BOOL m_bIsDeleted;
107 MUTEX m_hMutex; // Generic object access mutex
108 MUTEX m_mutexRefCount; // Reference counter access mutex
109 DWORD m_dwIpAddr; // Every object should have an IP address
110 DWORD m_dwImageId; // Custom image id or 0 if object has default image
111 ClientSession *m_pPollRequestor;
112
113 DWORD m_dwChildCount; // Number of child objects
114 NetObj **m_pChildList; // Array of pointers to child objects
115
116 DWORD m_dwParentCount; // Number of parent objects
117 NetObj **m_pParentList; // Array of pointers to parent objects
118
119 AccessList *m_pAccessList;
120 BOOL m_bInheritAccessRights;
121
122 void Lock(void) { MutexLock(m_hMutex, INFINITE); }
123 void Unlock(void) { MutexUnlock(m_hMutex); }
124
125 void Modify(void); // Used to mark object as modified
126
127 BOOL LoadACLFromDB(void);
128 BOOL SaveACLToDB(void);
129
130 void SendPollerMsg(DWORD dwRqId, TCHAR *pszFormat, ...);
131
132 virtual void OnObjectDelete(DWORD dwObjectId);
133
134 public:
135 NetObj();
136 virtual ~NetObj();
137
138 virtual int Type(void) { return OBJECT_GENERIC; }
139
140 DWORD IpAddr(void) { return m_dwIpAddr; }
141 DWORD Id(void) { return m_dwId; }
142 const char *Name(void) { return m_szName; }
143 int Status(void) { return m_iStatus; }
144
145 BOOL IsModified(void) { return m_bIsModified; }
146 BOOL IsDeleted(void) { return m_bIsDeleted; }
147 BOOL IsOrphaned(void) { return m_dwParentCount == 0 ? TRUE : FALSE; }
148 BOOL IsEmpty(void) { return m_dwChildCount == 0 ? TRUE : FALSE; }
149
150 DWORD RefCount(void);
151 void IncRefCount(void);
152 void DecRefCount(void);
153
154 BOOL IsChild(DWORD dwObjectId);
155
156 void AddChild(NetObj *pObject); // Add reference to child object
157 void AddParent(NetObj *pObject); // Add reference to parent object
158
159 void DeleteChild(NetObj *pObject); // Delete reference to child object
160 void DeleteParent(NetObj *pObject); // Delete reference to parent object
161
162 void Delete(BOOL bIndexLocked); // Prepare object for deletion
163
164 virtual BOOL SaveToDB(void);
165 virtual BOOL DeleteFromDB(void);
166 virtual BOOL CreateFromDB(DWORD dwId);
167
168 NetObj *GetParent(DWORD dwIndex = 0) { return dwIndex < m_dwParentCount ? m_pParentList[dwIndex] : NULL; }
169
170 void SetId(DWORD dwId) { m_dwId = dwId; Modify(); }
171 void SetMgmtStatus(BOOL bIsManaged);
172 void SetName(char *pszName) { strncpy(m_szName, pszName, MAX_OBJECT_NAME); Modify(); }
173
174 virtual void CalculateCompoundStatus(void);
175
176 virtual void CreateMessage(CSCPMessage *pMsg);
177 virtual DWORD ModifyFromMessage(CSCPMessage *pRequest, BOOL bAlreadyLocked = FALSE);
178
179 DWORD GetUserRights(DWORD dwUserId);
180 BOOL CheckAccessRights(DWORD dwUserId, DWORD dwRequiredRights);
181 void DropUserAccess(DWORD dwUserId);
182
183 void AddChildNodesToList(DWORD *pdwNumNodes, Node ***pppNodeList, DWORD dwUserId);
184
185 // Debug methods
186 const char *ParentList(char *szBuffer);
187 const char *ChildList(char *szBuffer);
188 };
189
190
191 //
192 // Inline functions of NetObj class
193 //
194
195 inline DWORD NetObj::RefCount(void)
196 {
197 DWORD dwRefCount;
198
199 MutexLock(m_mutexRefCount, INFINITE);
200 dwRefCount = m_dwRefCount;
201 MutexUnlock(m_mutexRefCount);
202 return dwRefCount;
203 }
204
205 inline void NetObj::IncRefCount(void)
206 {
207 MutexLock(m_mutexRefCount, INFINITE);
208 m_dwRefCount++;
209 MutexUnlock(m_mutexRefCount);
210 }
211
212 inline void NetObj::DecRefCount(void)
213 {
214 MutexLock(m_mutexRefCount, INFINITE);
215 if (m_dwRefCount > 0)
216 m_dwRefCount--;
217 MutexUnlock(m_mutexRefCount);
218 }
219
220
221 //
222 // Node template class
223 //
224
225 class NXCORE_EXPORTABLE Template : public NetObj
226 {
227 protected:
228 DWORD m_dwNumItems; // Number of data collection items
229 DCItem **m_ppItems; // Data collection items
230 DWORD m_dwDCILockStatus;
231 DWORD m_dwVersion;
232 TCHAR *m_pszDescription;
233 BOOL m_bDCIListModified;
234
235 void LoadItemsFromDB(void);
236 void DestroyItems(void);
237
238 public:
239 Template();
240 virtual ~Template();
241
242 virtual int Type(void) { return OBJECT_TEMPLATE; }
243
244 virtual BOOL SaveToDB(void);
245 virtual BOOL DeleteFromDB(void);
246 virtual BOOL CreateFromDB(DWORD dwId);
247
248 virtual void CreateMessage(CSCPMessage *pMsg);
249 virtual DWORD ModifyFromMessage(CSCPMessage *pRequest, BOOL bAlreadyLocked = FALSE);
250
251 virtual void CalculateCompoundStatus(void);
252
253 int VersionMajor(void) { return m_dwVersion >> 16; }
254 int VersionMinor(void) { return m_dwVersion & 0xFFFF; }
255 const TCHAR *Description(void) { return CHECK_NULL(m_pszDescription); }
256
257 BOOL AddItem(DCItem *pItem);
258 BOOL UpdateItem(DWORD dwItemId, CSCPMessage *pMsg, DWORD *pdwNumMaps,
259 DWORD **ppdwMapIndex, DWORD **ppdwMapId);
260 BOOL DeleteItem(DWORD dwItemId);
261 BOOL SetItemStatus(DWORD dwNumItems, DWORD *pdwItemList, int iStatus);
262 int GetItemType(DWORD dwItemId);
263 const DCItem *GetItemById(DWORD dwItemId);
264 BOOL LockDCIList(DWORD dwSessionId);
265 BOOL UnlockDCIList(DWORD dwSessionId);
266 void SetDCIModificationFlag(void) { m_bDCIListModified = TRUE; }
267 void SendItemsToClient(ClientSession *pSession, DWORD dwRqId);
268 BOOL IsLockedBySession(DWORD dwSessionId) { return m_dwDCILockStatus == dwSessionId; }
269 };
270
271
272 //
273 // Interface class
274 //
275
276 class NXCORE_EXPORTABLE Interface : public NetObj
277 {
278 protected:
279 DWORD m_dwIfIndex;
280 DWORD m_dwIfType;
281 DWORD m_dwIpNetMask;
282 BYTE m_bMacAddr[MAC_ADDR_LENGTH];
283
284 public:
285 Interface();
286 Interface(DWORD dwAddr, DWORD dwNetMask);
287 Interface(char *szName, DWORD dwIndex, DWORD dwAddr, DWORD dwNetMask, DWORD dwType);
288 virtual ~Interface();
289
290 virtual int Type(void) { return OBJECT_INTERFACE; }
291 virtual BOOL SaveToDB(void);
292 virtual BOOL DeleteFromDB(void);
293 virtual BOOL CreateFromDB(DWORD dwId);
294
295 Node *GetParentNode(void);
296
297 void SetMacAddr(BYTE *pbNewMac) { memcpy(m_bMacAddr, pbNewMac, MAC_ADDR_LENGTH); Modify(); }
298
299 DWORD IpNetMask(void) { return m_dwIpNetMask; }
300 DWORD IfIndex(void) { return m_dwIfIndex; }
301 DWORD IfType(void) { return m_dwIfType; }
302 const BYTE *MacAddr(void) { return m_bMacAddr; }
303
304 void StatusPoll(ClientSession *pSession, DWORD dwRqId);
305 virtual void CreateMessage(CSCPMessage *pMsg);
306
307 DWORD WakeUp(void);
308 };
309
310
311 //
312 // Network service class
313 //
314
315 class NetworkService : public NetObj
316 {
317 protected:
318 int m_iServiceType; // SSH, POP3, etc.
319 Node *m_pHostNode; // Pointer to node object which hosts this service
320 DWORD m_dwPollerNode; // ID of node object which is used for polling
321 // If 0, m_pHostNode->m_dwPollerNode will be used
322 WORD m_wProto; // Protocol (TCP, UDP, etc.)
323 WORD m_wPort; // TCP or UDP port number
324 TCHAR *m_pszRequest; // Service-specific request
325 TCHAR *m_pszResponce; // Service-specific expected responce
326
327 virtual void OnObjectDelete(DWORD dwObjectId);
328
329 public:
330 NetworkService();
331 NetworkService(int iServiceType, WORD wProto, WORD wPort,
332 TCHAR *pszRequest, TCHAR *pszResponce,
333 Node *pHostNode = NULL, DWORD dwPollerNode = 0);
334 virtual ~NetworkService();
335
336 virtual int Type(void) { return OBJECT_NETWORKSERVICE; }
337
338 virtual BOOL SaveToDB(void);
339 virtual BOOL DeleteFromDB(void);
340 virtual BOOL CreateFromDB(DWORD dwId);
341
342 void StatusPoll(ClientSession *pSession, DWORD dwRqId, Node *pPollerNode);
343
344 virtual void CreateMessage(CSCPMessage *pMsg);
345 virtual DWORD ModifyFromMessage(CSCPMessage *pRequest, BOOL bAlreadyLocked = FALSE);
346 };
347
348
349 //
350 // Node
351 //
352
353 class NXCORE_EXPORTABLE Node : public Template
354 {
355 protected:
356 DWORD m_dwFlags;
357 DWORD m_dwDiscoveryFlags;
358 DWORD m_dwDynamicFlags; // Flags used at runtime by server
359 WORD m_wAgentPort;
360 WORD m_wAuthMethod;
361 DWORD m_dwNodeType;
362 char m_szSharedSecret[MAX_SECRET_LENGTH];
363 int m_iStatusPollType;
364 int m_iSNMPVersion;
365 char m_szCommunityString[MAX_COMMUNITY_LENGTH];
366 char m_szObjectId[MAX_OID_LEN * 4];
367 char m_szAgentVersion[MAX_AGENT_VERSION_LEN];
368 char m_szPlatformName[MAX_PLATFORM_NAME_LEN];
369 DWORD m_dwNumParams; // Number of elements in supported parameters list
370 NXC_AGENT_PARAM *m_pParamList; // List of supported parameters
371 time_t m_tLastDiscoveryPoll;
372 time_t m_tLastStatusPoll;
373 time_t m_tLastConfigurationPoll;
374 int m_iSnmpAgentFails;
375 int m_iNativeAgentFails;
376 MUTEX m_hPollerMutex;
377 MUTEX m_hAgentAccessMutex;
378 AgentConnection *m_pAgentConnection;
379 DWORD m_dwPollerNode; // Node used for network service polling
380 QWORD m_qwLastEvents[MAX_LAST_EVENTS];
381
382 void PollerLock(void) { MutexLock(m_hPollerMutex, INFINITE); }
383 void PollerUnlock(void) { MutexUnlock(m_hPollerMutex); }
384
385 void AgentLock(void) { MutexLock(m_hAgentAccessMutex, INFINITE); }
386 void AgentUnlock(void) { MutexUnlock(m_hAgentAccessMutex); }
387
388 void CheckOSPFSupport(void);
389
390 virtual void OnObjectDelete(DWORD dwObjectId);
391
392 public:
393 Node();
394 Node(DWORD dwAddr, DWORD dwFlags, DWORD dwDiscoveryFlags);
395 virtual ~Node();
396
397 virtual int Type(void) { return OBJECT_NODE; }
398
399 virtual BOOL SaveToDB(void);
400 virtual BOOL DeleteFromDB(void);
401 virtual BOOL CreateFromDB(DWORD dwId);
402
403 DWORD Flags(void) { return m_dwFlags; }
404 DWORD DiscoveryFlags(void) { return m_dwDiscoveryFlags; }
405 DWORD RuntimeFlags(void) { return m_dwDynamicFlags; }
406
407 BOOL IsSNMPSupported(void) { return m_dwFlags & NF_IS_SNMP ? TRUE : FALSE; }
408 BOOL IsNativeAgent(void) { return m_dwFlags & NF_IS_NATIVE_AGENT ? TRUE : FALSE; }
409 BOOL IsBridge(void) { return m_dwFlags & NF_IS_BRIDGE ? TRUE : FALSE; }
410 BOOL IsRouter(void) { return m_dwFlags & NF_IS_ROUTER ? TRUE : FALSE; }
411 BOOL IsLocalManagement(void) { return m_dwFlags & NF_IS_LOCAL_MGMT ? TRUE : FALSE; }
412
413 const char *ObjectId(void) { return m_szObjectId; }
414
415 void AddInterface(Interface *pInterface) { AddChild(pInterface); pInterface->AddParent(this); }
416 void CreateNewInterface(DWORD dwAddr, DWORD dwNetMask, char *szName = NULL,
417 DWORD dwIndex = 0, DWORD dwType = 0, BYTE *pbMacAddr = NULL);
418 void DeleteInterface(Interface *pInterface);
419
420 void NewNodePoll(DWORD dwNetMask);
421
422 ARP_CACHE *GetArpCache(void);
423 INTERFACE_LIST *GetInterfaceList(void);
424 Interface *FindInterface(DWORD dwIndex, DWORD dwHostAddr);
425 int GetInterfaceStatusFromSNMP(DWORD dwIndex);
426 int GetInterfaceStatusFromAgent(DWORD dwIndex);
427
428 void SetDiscoveryPollTimeStamp(void) { m_tLastDiscoveryPoll = time(NULL); }
429 void StatusPoll(ClientSession *pSession, DWORD dwRqId);
430 void ConfigurationPoll(ClientSession *pSession, DWORD dwRqId);
431 BOOL ReadyForStatusPoll(void);
432 BOOL ReadyForConfigurationPoll(void);
433 BOOL ReadyForDiscoveryPoll(void);
434 void LockForStatusPoll(void);
435 void LockForConfigurationPoll(void);
436
437 virtual void CalculateCompoundStatus(void);
438
439 BOOL ConnectToAgent(void);
440 DWORD GetItemFromSNMP(const char *szParam, DWORD dwBufSize, char *szBuffer);
441 DWORD GetItemFromAgent(const char *szParam, DWORD dwBufSize, char *szBuffer);
442 DWORD GetInternalItem(const char *szParam, DWORD dwBufSize, char *szBuffer);
443 void QueueItemsForPolling(Queue *pPollerQueue);
444 DWORD GetItemForClient(int iOrigin, const char *pszParam, char *pszBuffer, DWORD dwBufSize);
445 DWORD GetLastValues(CSCPMessage *pMsg);
446 void CleanDCIData(void);
447
448 AgentConnection *CreateAgentConnection(void);
449
450 virtual void CreateMessage(CSCPMessage *pMsg);
451 virtual DWORD ModifyFromMessage(CSCPMessage *pRequest, BOOL bAlreadyLocked = FALSE);
452 void WriteParamListToMessage(CSCPMessage *pMsg);
453
454 DWORD WakeUp(void);
455
456 void AddService(NetworkService *pNetSrv) { AddChild(pNetSrv); pNetSrv->AddParent(this); }
457 DWORD CheckNetworkService(DWORD *pdwStatus, DWORD dwIpAddr, int iServiceType, WORD wPort = 0,
458 WORD wProto = 0, TCHAR *pszRequest = NULL, TCHAR *pszResponce = NULL);
459
460 QWORD LastEventId(int nIndex) { return ((nIndex >= 0) && (nIndex < MAX_LAST_EVENTS)) ? m_qwLastEvents[nIndex] : 0; }
461 };
462
463
464 //
465 // Inline functions for Node class
466 //
467
468 inline BOOL Node::ReadyForStatusPoll(void)
469 {
470 return ((m_iStatus != STATUS_UNMANAGED) &&
471 (!(m_dwDynamicFlags & NDF_QUEUED_FOR_STATUS_POLL)) &&
472 ((DWORD)time(NULL) - (DWORD)m_tLastStatusPoll > g_dwStatusPollingInterval))
473 ? TRUE : FALSE;
474 }
475
476 inline BOOL Node::ReadyForConfigurationPoll(void)
477 {
478 return ((m_iStatus != STATUS_UNMANAGED) &&
479 (!(m_dwDynamicFlags & NDF_QUEUED_FOR_CONFIG_POLL)) &&
480 ((DWORD)time(NULL) - (DWORD)m_tLastConfigurationPoll > g_dwConfigurationPollingInterval))
481 ? TRUE : FALSE;
482 }
483
484 inline BOOL Node::ReadyForDiscoveryPoll(void)
485 {
486 return ((m_iStatus != STATUS_UNMANAGED) &&
487 ((DWORD)time(NULL) - (DWORD)m_tLastDiscoveryPoll > g_dwDiscoveryPollingInterval))
488 ? TRUE : FALSE;
489 }
490
491 inline void Node::LockForStatusPoll(void)
492 {
493 Lock();
494 m_dwDynamicFlags |= NDF_QUEUED_FOR_STATUS_POLL;
495 Unlock();
496 }
497
498 inline void Node::LockForConfigurationPoll(void)
499 {
500 Lock();
501 m_dwDynamicFlags |= NDF_QUEUED_FOR_CONFIG_POLL;
502 Unlock();
503 }
504
505
506 //
507 // Subnet
508 //
509
510 class NXCORE_EXPORTABLE Subnet : public NetObj
511 {
512 protected:
513 DWORD m_dwIpNetMask;
514
515 public:
516 Subnet();
517 Subnet(DWORD dwAddr, DWORD dwNetMask);
518 virtual ~Subnet();
519
520 virtual int Type(void) { return OBJECT_SUBNET; }
521
522 virtual BOOL SaveToDB(void);
523 virtual BOOL DeleteFromDB(void);
524 virtual BOOL CreateFromDB(DWORD dwId);
525
526 void AddNode(Node *pNode) { AddChild(pNode); pNode->AddParent(this); }
527 virtual void CreateMessage(CSCPMessage *pMsg);
528
529 DWORD IpNetMask(void) { return m_dwIpNetMask; }
530 };
531
532
533 //
534 // Universal root object
535 //
536
537 class NXCORE_EXPORTABLE UniversalRoot : public NetObj
538 {
539 public:
540 UniversalRoot();
541 virtual ~UniversalRoot();
542
543 virtual BOOL SaveToDB(void);
544 virtual void LoadFromDB(void);
545 virtual const char *DefaultName(void) { return "Root Object"; }
546
547 void LinkChildObjects(void);
548 void LinkObject(NetObj *pObject) { AddChild(pObject); pObject->AddParent(this); }
549 };
550
551
552 //
553 // Entire network
554 //
555
556 class NXCORE_EXPORTABLE Network : public NetObj
557 {
558 public:
559 Network();
560 virtual ~Network();
561
562 virtual int Type(void) { return OBJECT_NETWORK; }
563 virtual BOOL SaveToDB(void);
564
565 void AddSubnet(Subnet *pSubnet) { AddChild(pSubnet); pSubnet->AddParent(this); }
566 void LoadFromDB(void);
567 };
568
569
570 //
571 // Service root
572 //
573
574 class NXCORE_EXPORTABLE ServiceRoot : public UniversalRoot
575 {
576 public:
577 ServiceRoot();
578 virtual ~ServiceRoot();
579
580 virtual int Type(void) { return OBJECT_SERVICEROOT; }
581 virtual const char *DefaultName(void) { return "All Services"; }
582 };
583
584
585 //
586 // Template root
587 //
588
589 class NXCORE_EXPORTABLE TemplateRoot : public UniversalRoot
590 {
591 public:
592 TemplateRoot();
593 virtual ~TemplateRoot();
594
595 virtual int Type(void) { return OBJECT_TEMPLATEROOT; }
596 virtual const char *DefaultName(void) { return "Templates"; }
597 virtual void CalculateCompoundStatus(void);
598 };
599
600
601 //
602 // Generic container object
603 //
604
605 class NXCORE_EXPORTABLE Container : public NetObj
606 {
607 private:
608 DWORD *m_pdwChildIdList;
609 DWORD m_dwChildIdListSize;
610
611 protected:
612 DWORD m_dwCategory;
613 char *m_pszDescription;
614
615 public:
616 Container();
617 Container(char *pszName, DWORD dwCategory, char *pszDescription);
618 virtual ~Container();
619
620 virtual int Type(void) { return OBJECT_CONTAINER; }
621
622 virtual BOOL SaveToDB(void);
623 virtual BOOL DeleteFromDB(void);
624 virtual BOOL CreateFromDB(DWORD dwId);
625
626 virtual void CreateMessage(CSCPMessage *pMsg);
627
628 DWORD Category(void) { return m_dwCategory; }
629 const TCHAR *Description(void) { return CHECK_NULL(m_pszDescription); }
630
631 void LinkChildObjects(void);
632 void LinkObject(NetObj *pObject) { AddChild(pObject); pObject->AddParent(this); }
633 };
634
635
636 //
637 // Template group object
638 //
639
640 class NXCORE_EXPORTABLE TemplateGroup : public Container
641 {
642 public:
643 TemplateGroup() : Container() { }
644 TemplateGroup(char *pszName, char *pszDescription) : Container(pszName, 0, pszDescription) { }
645 virtual ~TemplateGroup() { }
646
647 virtual int Type(void) { return OBJECT_TEMPLATEGROUP; }
648 };
649
650
651 //
652 // Object index structure
653 //
654
655 struct INDEX
656 {
657 DWORD dwKey;
658 NetObj *pObject;
659 };
660
661
662 //
663 // Container category information
664 //
665
666 struct CONTAINER_CATEGORY
667 {
668 DWORD dwCatId;
669 char szName[MAX_OBJECT_NAME];
670 char *pszDescription;
671 DWORD dwImageId;
672 };
673
674
675 //
676 // Functions
677 //
678
679 void ObjectsInit(void);
680
681 void NetObjInsert(NetObj *pObject, BOOL bNewObject);
682 void NetObjDeleteFromIndexes(NetObj *pObject);
683 void NetObjDelete(NetObj *pObject);
684
685 NetObj NXCORE_EXPORTABLE *FindObjectById(DWORD dwId);
686 Node NXCORE_EXPORTABLE *FindNodeByIP(DWORD dwAddr);
687 Subnet NXCORE_EXPORTABLE *FindSubnetByIP(DWORD dwAddr);
688 Subnet NXCORE_EXPORTABLE *FindSubnetForNode(DWORD dwNodeAddr);
689 DWORD NXCORE_EXPORTABLE FindLocalMgmtNode(void);
690 CONTAINER_CATEGORY NXCORE_EXPORTABLE *FindContainerCategory(DWORD dwId);
691
692 BOOL LoadObjects(void);
693 void DumpObjects(void);
694
695 void DeleteUserFromAllObjects(DWORD dwUserId);
696
697 BOOL IsValidParentClass(int iChildClass, int iParentClass);
698
699
700 //
701 // Global variables
702 //
703
704 extern Network *g_pEntireNet;
705 extern ServiceRoot *g_pServiceRoot;
706 extern TemplateRoot *g_pTemplateRoot;
707
708 extern DWORD g_dwMgmtNode;
709 extern INDEX *g_pIndexById;
710 extern DWORD g_dwIdIndexSize;
711 extern INDEX *g_pSubnetIndexByAddr;
712 extern DWORD g_dwSubnetAddrIndexSize;
713 extern INDEX *g_pNodeIndexByAddr;
714 extern DWORD g_dwNodeAddrIndexSize;
715 extern INDEX *g_pInterfaceIndexByAddr;
716 extern DWORD g_dwInterfaceAddrIndexSize;
717 extern RWLOCK g_rwlockIdIndex;
718 extern RWLOCK g_rwlockNodeIndex;
719 extern RWLOCK g_rwlockSubnetIndex;
720 extern RWLOCK g_rwlockInterfaceIndex;
721 extern DWORD g_dwNumCategories;
722 extern CONTAINER_CATEGORY *g_pContainerCatList;
723 extern char *g_szClassName[];
724
725
726 #endif /* _nms_objects_h_ */