Started work on forced polls
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 23 Sep 2004 08:20:20 +0000 (08:20 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 23 Sep 2004 08:20:20 +0000 (08:20 +0000)
include/nms_cscp.h
include/nxclapi.h
src/libnxcl/main.cpp
src/libnxcl/objects.cpp
src/server/core/nms_core.h
src/server/core/session.cpp

index 6682934..79723af 100644 (file)
@@ -251,6 +251,8 @@ typedef struct
 #define CMD_DELETE_CONTAINER_CAT    0x0056
 #define CMD_CREATE_CONTAINER_CAT    0x0057
 #define CMD_MODIFY_CONTAINER_CAT    0x0058
+#define CMD_POLL_NODE               0x0059
+#define CMD_POLLING_INFO            0x005A
 
 
 //
@@ -363,6 +365,8 @@ typedef struct
 #define VID_CATEGORY_ID             ((DWORD)104)
 #define VID_DCI_DELTA_CALCULATION   ((DWORD)105)
 #define VID_DCI_FORMULA             ((DWORD)106)
+#define VID_POLL_TYPE               ((DWORD)107)
+#define VID_POLLER_MESSAGE          ((DWORD)108)
 
 // Variable ranges for object's ACL
 #define VID_ACL_USER_BASE           ((DWORD)0x00001000)
index bd6ab02..25c43ff 100644 (file)
@@ -88,6 +88,14 @@ typedef unsigned long HREQUEST;
 #define AUTH_SHA1_HASH        3
 
 
+//
+// Forced poll types
+//
+
+#define POLL_STATUS           1
+#define POLL_CONFIGURATION    2
+
+
 //
 // Object types
 //
@@ -214,6 +222,7 @@ typedef unsigned long HREQUEST;
 #define RCC_INVALID_OBJECT_NAME     ((DWORD)20)
 #define RCC_INVALID_ALARM_ID        ((DWORD)21)
 #define RCC_INVALID_ACTION_ID       ((DWORD)22)
+#define RCC_OPERATION_IN_PROGRESS   ((DWORD)23)
 
 
 //
@@ -808,6 +817,7 @@ DWORD LIBNXCL_EXPORTABLE NXCCreateObject(NXC_OBJECT_CREATE_INFO *pCreateInfo, DW
 DWORD LIBNXCL_EXPORTABLE NXCBindObject(DWORD dwParentObject, DWORD dwChildObject);
 DWORD LIBNXCL_EXPORTABLE NXCUnbindObject(DWORD dwParentObject, DWORD dwChildObject);
 DWORD LIBNXCL_EXPORTABLE NXCDeleteObject(DWORD dwObject);
+DWORD LIBNXCL_EXPORTABLE NXCPollNode(DWORD dwObjectId, int iPollType, void (* pCallback)(TCHAR *));
 
 DWORD LIBNXCL_EXPORTABLE NXCLoadCCList(NXC_CC_LIST **ppList);
 void LIBNXCL_EXPORTABLE NXCDestroyCCList(NXC_CC_LIST *pList);
index dfd9b55..60b6ebf 100644 (file)
@@ -115,9 +115,10 @@ const char LIBNXCL_EXPORTABLE *NXCGetErrorText(DWORD dwError)
       "Loop in object relationship detected",
       "Invalid object name",
       "Invalid alarm ID",
-      "Invalid action ID"
+      "Invalid action ID",
+      "Operation in progress"
    };
-   return ((dwError >= 0) && (dwError <= RCC_INVALID_ACTION_ID)) ? pszErrorText[dwError] : "Unknown error code";
+   return ((dwError >= 0) && (dwError <= RCC_OPERATION_IN_PROGRESS)) ? pszErrorText[dwError] : "Unknown error code";
 }
 
 
index af3e550..61b8858 100644 (file)
@@ -678,3 +678,46 @@ void LIBNXCL_EXPORTABLE NXCDestroyCCList(NXC_CC_LIST *pList)
    safe_free(pList->pElements);
    free(pList);
 }
+
+
+//
+// Perform a forced node poll
+//
+
+DWORD LIBNXCL_EXPORTABLE NXCPollNode(DWORD dwObjectId, int iPollType, void (* pfCallback)(TCHAR *))
+{
+   DWORD dwRetCode, dwRqId;
+   CSCPMessage msg, *pResponce;
+   TCHAR *pszMsg;
+
+   dwRqId = g_dwMsgId++;
+
+   msg.SetCode(CMD_POLL_NODE);
+   msg.SetId(dwRqId);
+   msg.SetVariable(VID_OBJECT_ID, dwObjectId);
+   msg.SetVariable(VID_POLL_TYPE, (WORD)iPollType);
+   SendMsg(&msg);
+
+   do
+   {
+      pResponce = WaitForMessage(CMD_POLLING_INFO, dwRqId, 10000);
+      if (pResponce != NULL)
+      {
+         dwRetCode = pResponce->GetVariableLong(VID_RCC);
+         if ((dwRetCode == RCC_OPERATION_IN_PROGRESS) && (pfCallback != NULL))
+         {
+            pszMsg = pResponce->GetVariableStr(VID_POLLER_MESSAGE);
+            pfCallback(pszMsg);
+            free(pszMsg);
+         }
+         delete pResponce;
+      }
+      else
+      {
+         dwRetCode = RCC_TIMEOUT;
+      }
+   }
+   while(dwRetCode == RCC_OPERATION_IN_PROGRESS);
+
+   return dwRetCode;
+}
index f7af26f..2ee7ead 100644 (file)
@@ -295,6 +295,7 @@ private:
    void LockActionDB(DWORD dwRqId, BOOL bLock);
    void SendAllActions(DWORD dwRqId);
    void SendContainerCategories(DWORD dwRqId);
+   void ForcedNodePoll(CSCPMessage *pRequest);
 
 public:
    ClientSession(SOCKET hSocket, DWORD dwHostAddr);
index 6e57943..0712cd0 100644 (file)
@@ -529,6 +529,9 @@ void ClientSession::ProcessingThread(void)
          case CMD_DELETE_OBJECT:
             DeleteObject(pMsg);
             break;
+         case CMD_POLL_NODE:
+            ForcedNodePoll(pMsg);
+            break;
          default:
             break;
       }
@@ -2587,3 +2590,12 @@ void ClientSession::SendContainerCategories(DWORD dwRqId)
    msg.SetVariable(VID_CATEGORY_ID, (DWORD)0);
    SendMessage(&msg);
 }
+
+
+//
+// Perform a forced node poll
+//
+
+void ClientSession::ForcedNodePoll(CSCPMessage *pRequest)
+{
+}