Added support for NetworkService object class
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 21 Jan 2005 21:16:51 +0000 (21:16 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 21 Jan 2005 21:16:51 +0000 (21:16 +0000)
include/nms_cscp.h
include/nxclapi.h
src/libnxcl/objects.cpp

index e7094fd..9740527 100644 (file)
@@ -421,7 +421,7 @@ typedef struct
 #define VID_IP_PORT                 ((DWORD)132)
 #define VID_SERVICE_REQUEST         ((DWORD)133)
 #define VID_SERVICE_RESPONCE        ((DWORD)134)
-#define VID_POLL_NODE_ID            ((DWORD)135)
+#define VID_POLLER_NODE_ID          ((DWORD)135)
 
 // Variable ranges for object's ACL
 #define VID_ACL_USER_BASE           ((DWORD)0x00001000)
index dd8a9e3..a6cc3a8 100644 (file)
@@ -281,7 +281,15 @@ typedef void * NXC_SESSION;
 #define OBJ_UPDATE_ACL              ((DWORD)0x0040)
 #define OBJ_UPDATE_IMAGE            ((DWORD)0x0080)
 #define OBJ_UPDATE_DESCRIPTION      ((DWORD)0x0100)
-#define OBJ_UPDATE_ALL              ((DWORD)0x01FF)
+#define OBJ_UPDATE_SERVICE_TYPE     ((DWORD)0x0200)
+#define OBJ_UPDATE_IP_PROTO         ((DWORD)0x0400)
+#define OBJ_UPDATE_IP_PORT          ((DWORD)0x0800)
+#define OBJ_UPDATE_CHECK_REQUEST    ((DWORD)0x1000)
+#define OBJ_UPDATE_CHECK_RESPONCE   ((DWORD)0x2000)
+#define OBJ_UPDATE_POLLER_NODE      ((DWORD)0x4000)
+
+#define OBJ_UPDATE_NODE_ALL         ((DWORD)0x01FF)
+#define OBJ_UPDATE_NETSRV_ALL       ((DWORD)0x7EC1)
 
 
 //
@@ -639,6 +647,15 @@ typedef struct
          DWORD dwVersion;
          TCHAR *pszDescription;
       } dct;
+      struct
+      {
+         int iServiceType;
+         WORD wProto;
+         WORD wPort;
+         DWORD dwPollerNode;
+         TCHAR *pszRequest;
+         TCHAR *pszResponce;
+      } netsrv;
    };
 } NXC_OBJECT;
 
@@ -662,6 +679,12 @@ typedef struct
    DWORD dwAclSize;
    NXC_ACL_ENTRY *pAccessList;
    WORD wSNMPVersion;
+   int iServiceType;
+   WORD wProto;
+   WORD wPort;
+   DWORD dwPollerNode;
+   TCHAR *pszRequest;
+   TCHAR *pszResponce;
 } NXC_OBJECT_UPDATE;
 
 
index 99eb9f3..ea88e89 100644 (file)
@@ -42,6 +42,10 @@ void DestroyObject(NXC_OBJECT *pObject)
       case OBJECT_TEMPLATE:
          safe_free(pObject->dct.pszDescription);
          break;
+      case OBJECT_NETWORKSERVICE:
+         safe_free(pObject->netsrv.pszRequest);
+         safe_free(pObject->netsrv.pszResponce);
+         break;
    }
    safe_free(pObject->pdwChildList);
    safe_free(pObject->pdwParentList);
@@ -123,8 +127,22 @@ void NXCL_Session::AddObject(NXC_OBJECT *pObject, BOOL bSortIndex)
 static void ReplaceObject(NXC_OBJECT *pObject, NXC_OBJECT *pNewObject)
 {
    DebugPrintf(_T("ReplaceObject(id:%ld, name:\"%s\")"), pObject->dwId, pObject->szName);
-   if (pObject->iClass == OBJECT_CONTAINER)
-      safe_free(pObject->container.pszDescription);
+   switch(pObject->iClass)
+   {
+      case OBJECT_CONTAINER:
+         safe_free(pObject->container.pszDescription);
+         break;
+      case OBJECT_NODE:
+         safe_free(pObject->node.pszDescription);
+         break;
+      case OBJECT_TEMPLATE:
+         safe_free(pObject->dct.pszDescription);
+         break;
+      case OBJECT_NETWORKSERVICE:
+         safe_free(pObject->netsrv.pszRequest);
+         safe_free(pObject->netsrv.pszResponce);
+         break;
+   }
    safe_free(pObject->pdwChildList);
    safe_free(pObject->pdwParentList);
    safe_free(pObject->pAccessList);
@@ -212,6 +230,14 @@ static NXC_OBJECT *NewObjectFromMsg(CSCPMessage *pMsg)
          pObject->dct.dwVersion = pMsg->GetVariableLong(VID_TEMPLATE_VERSION);
          pObject->dct.pszDescription = pMsg->GetVariableStr(VID_DESCRIPTION);
          break;
+      case OBJECT_NETWORKSERVICE:
+         pObject->netsrv.iServiceType = (int)pMsg->GetVariableShort(VID_SERVICE_TYPE);
+         pObject->netsrv.wProto = pMsg->GetVariableShort(VID_IP_PROTO);
+         pObject->netsrv.wPort = pMsg->GetVariableShort(VID_IP_PORT);
+         pObject->netsrv.dwPollerNode = pMsg->GetVariableShort(VID_POLLER_NODE_ID);
+         pObject->netsrv.pszRequest = pMsg->GetVariableStr(VID_SERVICE_REQUEST);
+         pObject->netsrv.pszResponce = pMsg->GetVariableStr(VID_SERVICE_RESPONCE);
+         break;
       default:
          break;
    }
@@ -489,6 +515,16 @@ DWORD LIBNXCL_EXPORTABLE NXCModifyObject(NXC_SESSION hSession, NXC_OBJECT_UPDATE
       msg.SetVariable(VID_SNMP_VERSION, pUpdate->wSNMPVersion);
    if (pUpdate->dwFlags & OBJ_UPDATE_DESCRIPTION)
       msg.SetVariable(VID_DESCRIPTION, pUpdate->pszDescription);
+   if (pUpdate->dwFlags & OBJ_UPDATE_CHECK_REQUEST)
+      msg.SetVariable(VID_SERVICE_REQUEST, pUpdate->pszRequest);
+   if (pUpdate->dwFlags & OBJ_UPDATE_CHECK_RESPONCE)
+      msg.SetVariable(VID_SERVICE_RESPONCE, pUpdate->pszResponce);
+   if (pUpdate->dwFlags & OBJ_UPDATE_IP_PROTO)
+      msg.SetVariable(VID_IP_PROTO, pUpdate->wProto);
+   if (pUpdate->dwFlags & OBJ_UPDATE_IP_PORT)
+      msg.SetVariable(VID_IP_PORT, pUpdate->wPort);
+   if (pUpdate->dwFlags & OBJ_UPDATE_SERVICE_TYPE)
+      msg.SetVariable(VID_SERVICE_TYPE, (WORD)pUpdate->iServiceType);
    if (pUpdate->dwFlags & OBJ_UPDATE_ACL)
    {
       DWORD i, dwId1, dwId2;