- Fixed bug in loading of NetworkService objects from database
authorVictor Kirhenshtein <victor@netxms.org>
Mon, 14 Feb 2005 21:31:02 +0000 (21:31 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Mon, 14 Feb 2005 21:31:02 +0000 (21:31 +0000)
- Fixed bug in interface status detection via NetXMS agent
- Added support for NAT'ed nodes (correct interface polling, etc.)
- Backslash (\) character is no longer works as escape character inside parameter arguments enclosed in quotes
- Started work on deployment viewer in Windows console

20 files changed:
.gitattributes
ChangeLog
doc/client_library.doc
include/nms_common.h
include/nxclapi.h
src/agent/subagents/winperf/winperf.cpp
src/console/win32/DeploymentView.cpp [new file with mode: 0644]
src/console/win32/DeploymentView.h [new file with mode: 0644]
src/console/win32/PackageMgr.cpp
src/console/win32/PackageMgr.h
src/console/win32/nxcon.clw
src/console/win32/nxcon.cpp
src/console/win32/nxcon.dsp
src/console/win32/nxcon.h
src/libnetxms/tools.cpp
src/server/core/interface.cpp
src/server/core/netsrv.cpp
src/server/core/node.cpp
src/server/include/nms_objects.h
src/server/tools/nxdbmgr/upgrade.cpp

index 08a1c96..241785b 100644 (file)
@@ -310,6 +310,8 @@ src/console/win32/DataQueryDlg.cpp -text
 src/console/win32/DataQueryDlg.h -text
 src/console/win32/DebugFrame.cpp -text
 src/console/win32/DebugFrame.h -text
+src/console/win32/DeploymentView.cpp -text
+src/console/win32/DeploymentView.h -text
 src/console/win32/EditActionDlg.cpp -text
 src/console/win32/EditActionDlg.h -text
 src/console/win32/EditBox.cpp -text
index 223b42b..b841385 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,11 @@
 *
 
 - Parameters System.Memory.* behaves correctly under Windows
+- Fixed bug in loading of NetworkService objects from database
+- Fixed bug in interface status detection via NetXMS agent
+- Added support for NAT'ed nodes (correct interface polling, etc.)
+- Backslash (\) character is no longer works as escape character
+  inside parameter arguments enclosed in quotes
 
 
 *
index 695dfda..138327c 100644 (file)
Binary files a/doc/client_library.doc and b/doc/client_library.doc differ
index f994d54..9272d25 100644 (file)
@@ -314,6 +314,8 @@ typedef int SOCKET;
 #define IFTYPE_SMDS                 31
 #define IFTYPE_FRAME_RELAY          32
 
+#define IFTYPE_NETXMS_NAT_ADAPTER   65535
+
 
 //
 // IP Header -- RFC 791
index bd0e0b7..c6d970d 100644 (file)
@@ -157,6 +157,7 @@ typedef void * NXC_SESSION;
 #define NF_IS_LOCAL_MGMT   0x0010
 #define NF_IS_PRINTER      0x0020
 #define NF_IS_OSPF         0x0040
+#define NF_BEHIND_NAT      0x0080
 
 
 //
index 55b086a..b47a7c6 100644 (file)
@@ -132,6 +132,8 @@ static LONG H_PdhCounterValue(TCHAR *pszParam, TCHAR *pArg, TCHAR *pValue)
       return SYSINFO_RC_UNSUPPORTED;
 
    bUseTwoSamples = _tcstol(szBuffer, NULL, 0) ? TRUE : FALSE;
+printf("PARAM1=%s\n", szCounter);
+printf("PARAM2=%s\n", szBuffer);
 
    if ((rc = PdhOpenQuery(NULL, 0, &hQuery)) != ERROR_SUCCESS)
    {
diff --git a/src/console/win32/DeploymentView.cpp b/src/console/win32/DeploymentView.cpp
new file mode 100644 (file)
index 0000000..0186621
--- /dev/null
@@ -0,0 +1,35 @@
+// DeploymentView.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "nxcon.h"
+#include "DeploymentView.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CDeploymentView
+
+IMPLEMENT_DYNCREATE(CDeploymentView, CMDIChildWnd)
+
+CDeploymentView::CDeploymentView()
+{
+}
+
+CDeploymentView::~CDeploymentView()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CDeploymentView, CMDIChildWnd)
+       //{{AFX_MSG_MAP(CDeploymentView)
+               // NOTE - the ClassWizard will add and remove mapping macros here.
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CDeploymentView message handlers
diff --git a/src/console/win32/DeploymentView.h b/src/console/win32/DeploymentView.h
new file mode 100644 (file)
index 0000000..4186f18
--- /dev/null
@@ -0,0 +1,46 @@
+#if !defined(AFX_DEPLOYMENTVIEW_H__AA3A80C6_AA65_4D60_A4CF_930B055CA6C8__INCLUDED_)
+#define AFX_DEPLOYMENTVIEW_H__AA3A80C6_AA65_4D60_A4CF_930B055CA6C8__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// DeploymentView.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CDeploymentView frame
+
+class CDeploymentView : public CMDIChildWnd
+{
+       DECLARE_DYNCREATE(CDeploymentView)
+protected:
+       CDeploymentView();           // protected constructor used by dynamic creation
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CDeploymentView)
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+       virtual ~CDeploymentView();
+
+       // Generated message map functions
+       //{{AFX_MSG(CDeploymentView)
+               // NOTE - the ClassWizard will add and remove member functions here.
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_DEPLOYMENTVIEW_H__AA3A80C6_AA65_4D60_A4CF_930B055CA6C8__INCLUDED_)
index 6b2bb5c..0707cc9 100644 (file)
@@ -40,6 +40,8 @@ BEGIN_MESSAGE_MAP(CPackageMgr, CMDIChildWnd)
        ON_WM_CONTEXTMENU()
        ON_UPDATE_COMMAND_UI(ID_PACKAGE_REMOVE, OnUpdatePackageRemove)
        ON_COMMAND(ID_PACKAGE_REMOVE, OnPackageRemove)
+       ON_COMMAND(ID_PACKAGE_DEPLOY, OnPackageDeploy)
+       ON_UPDATE_COMMAND_UI(ID_PACKAGE_DEPLOY, OnUpdatePackageDeploy)
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -272,6 +274,11 @@ void CPackageMgr::OnUpdatePackageRemove(CCmdUI* pCmdUI)
    pCmdUI->Enable(m_wndListCtrl.GetSelectedCount() > 0);
 }
 
+void CPackageMgr::OnUpdatePackageDeploy(CCmdUI* pCmdUI) 
+{
+   pCmdUI->Enable(m_wndListCtrl.GetSelectedCount() == 1);
+}
+
 
 //
 // Worker function for package deletion
@@ -330,3 +337,27 @@ void CPackageMgr::OnPackageRemove()
       free(pdwDeleteList);
    }
 }
+
+
+//
+// WM_COMMAND::ID_PACKAGE_DEPLOY message handler
+//
+
+void CPackageMgr::OnPackageDeploy() 
+{
+   int iItem;
+
+   iItem = m_wndListCtrl.GetSelectionMark();
+   if (iItem != -1)
+   {
+      CObjectSelDlg dlg;
+
+      dlg.m_bAllowEmptySelection = FALSE;
+      dlg.m_dwAllowedClasses = SCL_NODE | SCL_CONTAINER | SCL_SUBNET | SCL_NETWORK | SCL_SERVICEROOT;
+      if (dlg.DoModal() == IDOK)
+      {
+         theApp.DeployPackage(m_wndListCtrl.GetItemData(iItem), dlg.m_dwNumObjects,
+                              dlg.m_pdwObjectList);
+      }
+   }
+}
index 3cdbe7d..d0769ea 100644 (file)
@@ -50,6 +50,8 @@ protected:
        afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
        afx_msg void OnUpdatePackageRemove(CCmdUI* pCmdUI);
        afx_msg void OnPackageRemove();
+       afx_msg void OnPackageDeploy();
+       afx_msg void OnUpdatePackageDeploy(CCmdUI* pCmdUI);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 };
index 2277060..73b52de 100644 (file)
@@ -2,13 +2,13 @@
 
 [General Info]
 Version=1
-LastClass=CNodePropsGeneral
-LastTemplate=CPropertyPage
+LastClass=CDeploymentView
+LastTemplate=CMDIChildWnd
 NewFileInclude1=#include "stdafx.h"
 NewFileInclude2=#include "nxcon.h"
 LastPage=0
 
-ClassCount=80
+ClassCount=81
 Class1=CConsoleApp
 Class3=CMainFrame
 Class4=CChildFrame
@@ -16,9 +16,9 @@ Class7=CEventBrowser
 Class9=CMapView
 
 ResourceCount=113
-Resource1=IDD_EDIT_RULE_ALARM (English (U.S.))
+Resource1=IDD_DCI_COLLECTION (English (U.S.))
 Resource2=IDD_OBJECT_NODE_GENERAL
-Resource3=IDA_MDI_DEFAULT (English (U.S.))
+Resource3=IDD_EDIT_TRAP (English (U.S.))
 Resource4=IDD_SELECT_OBJECT
 Resource5=IDD_SELECT_ACTION
 Class2=CChildView
@@ -32,9 +32,9 @@ Resource7=IDD_NEW_USER
 Class12=CObjectBrowser
 Resource8=IDD_CREATE_CONTAINER
 Class13=CObjectPropDlg
-Resource9=IDD_CREATE_TG (English (U.S.))
-Resource10=IDA_NETMAP (English (U.S.))
-Resource11=IDD_OBJECT_SECURITY (English (U.S.))
+Resource9=IDD_EDIT_RULE_SEVERITY (English (U.S.))
+Resource10=IDD_SELECT_AGENT_PARAM (English (U.S.))
+Resource11=IDA_GRAPH (English (U.S.))
 Resource12=IDR_CTRLPANEL (English (U.S.))
 Resource13=IDR_EVENTS (English (U.S.))
 Resource14=IDR_MAPFRAME (English (U.S.))
@@ -42,33 +42,33 @@ Resource15=IDR_OBJECTS (English (U.S.))
 Resource16=IDD_DUMMY (English (U.S.))
 Class14=CEventEditor
 Class15=CEditEventDlg
-Resource17=IDD_DCI_THRESHOLDS (English (U.S.))
+Resource17=IDD_REQUEST_PROCESSING (English (U.S.))
 Class16=CDebugFrame
-Resource18=IDD_OBJECT_NODE_GENERAL (English (U.S.))
+Resource18=IDA_NETMAP (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
 Resource20=IDD_SELECT_EVENT
 Class17=CObjectPreview
-Resource21=IDD_SELECT_AGENT_PARAM (English (U.S.))
+Resource21=IDD_CREATE_NODE (English (U.S.))
 Class18=CToolBox
 Class19=CObjectInfoBox
 Class20=CObjectSearchBox
-Resource22=IDD_CREATE_CONTAINER (English (U.S.))
+Resource22=IDD_EDIT_RULE_COMMENT (English (U.S.))
 Class21=CEditBox
 Class22=COPGeneral
 Class23=CNodePropsGeneral
-Resource23=IDD_REQUEST_PROCESSING (English (U.S.))
+Resource23=IDA_ACTION_EDITOR (English (U.S.))
 Class24=CObjectPropCaps
 Class25=CObjectPropSheet
 Resource24=IDA_MDI_DEFAULT
 Class26=CRequestProcessingDlg
-Resource25=IDD_OBJECT_GENERAL (English (U.S.))
+Resource25=IDA_TRAP_EDITOR (English (U.S.))
 Resource26=IDD_PROGRESS (English (U.S.))
 Resource27=IDD_EDIT_RULE_ALARM
-Resource28=IDD_LOGIN (English (U.S.))
+Resource28=IDA_EPP (English (U.S.))
 Class27=CObjectPropsGeneral
-Resource29=IDA_ACTION_EDITOR (English (U.S.))
+Resource29=IDD_CREATE_NETSRV (English (U.S.))
 Class28=CObjectPropsSecurity
-Resource30=IDD_GRAPH_PROPERTIES (English (U.S.))
+Resource30=IDD_SELECT_ACTION (English (U.S.))
 Resource31=IDD_SELECT_USER
 Resource32=IDD_OBJECT_SECURITY
 Class29=CUserSelectDlg
@@ -79,36 +79,36 @@ Class31=CNewUserDlg
 Resource35=IDD_THRESHOLD
 Resource36=IDA_EPP
 Class32=CUserPropDlg
-Resource37=IDA_OBJECT_BROWSER (English (U.S.))
+Resource37=IDD_EDIT_TRAP_ARG (English (U.S.))
 Resource38=IDD_ABOUTBOX
 Class33=CGroupPropDlg
 Resource39=IDD_CP_GENERAL
 Resource40=IDA_TRAP_EDITOR
 Resource41=IDM_VIEW_SPECIFIC
-Resource42=IDD_THRESHOLD (English (U.S.))
+Resource42=IDD_OBJECT_GENERAL (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
 Class36=CNetSummaryFrame
 Class37=CDataCollectionEditor
-Resource43=IDD_EDIT_TRAP (English (U.S.))
+Resource43=IDD_NEW_ACTION (English (U.S.))
 Class38=CDCIPropPage
-Resource44=IDD_DCI_COLLECTION (English (U.S.))
+Resource44=IDD_OBJECT_CAPS (English (U.S.))
 Class39=CDCIDataView
-Resource45=IDD_OBJECT_NETSRV_GENERAL (English (U.S.))
+Resource45=IDD_CREATE_TEMPLATE (English (U.S.))
 Class40=CGraph
 Class41=CGraphFrame
 Class42=CDCIThresholdsPage
-Resource46=IDD_CREATE_TEMPLATE (English (U.S.))
-Resource47=IDD_USER_PROPERTIES (English (U.S.))
+Resource46=IDD_EDIT_RULE_ALARM (English (U.S.))
+Resource47=IDD_LOGIN (English (U.S.))
 Resource48=IDM_CONTEXT
 Class43=CThresholdDlg
-Resource49=IDD_MIB_BROWSER (English (U.S.))
+Resource49=IDD_OBJECT_SECURITY (English (U.S.))
 Resource50=IDD_EDIT_TRAP_ARG
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
 Class46=CRuleList
 Class47=CRuleHeader
-Resource51=IDA_EPP (English (U.S.))
+Resource51=IDD_GRAPH_PROPERTIES (English (U.S.))
 Resource52=IDD_CREATE_NODE
 Class48=CObjectSelDlg
 Resource53=IDD_OBJECT_CAPS
@@ -117,22 +117,22 @@ Class49=CRuleCommentDlg
 Resource55=IDD_DCI_COLLECTION
 Class50=CEventSelDlg
 Resource56=IDD_DATA_QUERY
-Resource57=IDD_GROUP_PROPERTIES (English (U.S.))
+Resource57=IDD_EDIT_EVENT (English (U.S.))
 Resource58=IDD_CREATE_TG
-Resource59=IDD_SELECT_OBJECT (English (U.S.))
-Resource60=IDD_NEW_ACTION (English (U.S.))
+Resource59=IDD_SELECT_USER (English (U.S.))
+Resource60=IDD_THRESHOLD (English (U.S.))
 Class51=CObjectPropsPresentation
-Resource61=IDD_SELECT_ACTION (English (U.S.))
+Resource61=IDD_SELECT_OBJECT (English (U.S.))
 Resource62=IDD_EDIT_RULE_COMMENT
 Class52=CRuleSeverityDlg
 Resource63=IDD_ACTION_PROPERTIES
 Class53=CRuleAlarmDlg
 Class54=CAlarmBrowser
-Resource64=IDD_EDIT_EVENT (English (U.S.))
+Resource64=IDA_ALARM_BROWSER (English (U.S.))
 Resource65=IDD_DCI_TRANSFORM
-Resource66=IDA_ALARM_BROWSER (English (U.S.))
-Resource67=IDD_CP_GENERAL (English (U.S.))
-Resource68=IDD_SELECT_EVENT (English (U.S.))
+Resource66=IDD_SELECT_INTERNAL_ITEM (English (U.S.))
+Resource67=IDD_DCI_THRESHOLDS (English (U.S.))
+Resource68=IDD_USER_PROPERTIES (English (U.S.))
 Class55=CConsolePropsGeneral
 Class56=CActionEditor
 Resource69=IDA_ACTION_EDITOR
@@ -143,18 +143,18 @@ Class58=CEditActionDlg
 Resource72=IDA_NETMAP
 Class59=CActionSelDlg
 Resource73=IDD_MIB_BROWSER
-Resource74=IDD_OBJECT_PRESENTATION (English (U.S.))
-Resource75=IDD_DCI_TRANSFORM (English (U.S.))
+Resource74=IDD_GROUP_PROPERTIES (English (U.S.))
+Resource75=IDD_OBJECT_PRESENTATION (English (U.S.))
 Resource76=IDD_USER_PROPERTIES
 Class60=CCreateObjectDlg
 Class61=CCreateContainerDlg
 Resource77=IDR_MAINFRAME
 Class62=CCreateNodeDlg
-Resource78=IDA_EVENT_EDITOR (English (U.S.))
-Resource79=IDD_EDIT_TRAP_ARG (English (U.S.))
-Resource80=IDD_SET_PASSWORD (English (U.S.))
+Resource78=IDD_INPUT_BOX (English (U.S.))
+Resource79=IDD_ACTION_PROPERTIES (English (U.S.))
+Resource80=IDD_OBJECT_NODE_GENERAL (English (U.S.))
 Class63=CDCITransformPage
-Resource81=IDD_DATA_QUERY (English (U.S.))
+Resource81=IDD_CP_GENERAL (English (U.S.))
 Class64=CPollNodeDlg
 Resource82=IDD_POLL_NODE (English (U.S.))
 Class65=CNodePoller
@@ -180,29 +180,30 @@ Class73=CColorSelector
 Class74=CPackageMgr
 Resource94=IDD_GROUP_PROPERTIES
 Resource95=IDD_GRAPH_PROPERTIES
-Resource96=IDA_TRAP_EDITOR (English (U.S.))
-Resource97=IDA_GRAPH (English (U.S.))
-Resource98=IDA_PACKAGE_MGR (English (U.S.))
-Resource99=IDD_ABOUTBOX (English (U.S.))
-Resource100=IDD_EDIT_RULE_COMMENT (English (U.S.))
-Resource101=IDD_EDIT_RULE_SEVERITY (English (U.S.))
-Resource102=IDD_INPUT_BOX (English (U.S.))
-Resource103=IDD_CREATE_NETSRV (English (U.S.))
-Resource104=IDR_MAINFRAME (English (U.S.))
-Resource105=IDM_CONTEXT (English (U.S.))
-Resource106=IDM_VIEW_SPECIFIC (English (U.S.))
-Resource107=IDD_NEW_USER (English (U.S.))
+Resource96=IDD_OBJECT_NETSRV_GENERAL (English (U.S.))
+Resource97=IDR_MAINFRAME (English (U.S.))
+Resource98=IDA_MDI_DEFAULT (English (U.S.))
+Resource99=IDA_OBJECT_BROWSER (English (U.S.))
+Resource100=IDD_NEW_USER (English (U.S.))
+Resource101=IDD_SET_PASSWORD (English (U.S.))
+Resource102=IDD_DCI_TRANSFORM (English (U.S.))
+Resource103=IDD_CREATE_TG (English (U.S.))
+Resource104=IDD_DATA_QUERY (English (U.S.))
+Resource105=IDM_VIEW_SPECIFIC (English (U.S.))
+Resource106=IDM_CONTEXT (English (U.S.))
+Resource107=IDD_ABOUTBOX (English (U.S.))
 Class75=CInternalItemSelDlg
-Resource108=IDD_ACTION_PROPERTIES (English (U.S.))
+Resource108=IDD_MIB_BROWSER (English (U.S.))
 Class76=CAgentParamSelDlg
-Resource109=IDD_SELECT_USER (English (U.S.))
+Resource109=IDA_PACKAGE_MGR (English (U.S.))
 Class77=CInputBox
-Resource110=IDD_SELECT_INTERNAL_ITEM (English (U.S.))
+Resource110=IDD_CREATE_CONTAINER (English (U.S.))
 Class78=CCreateNetSrvDlg
-Resource111=IDD_OBJECT_CAPS (English (U.S.))
+Resource111=IDA_EVENT_EDITOR (English (U.S.))
 Class79=CNetSrvPropsGeneral
-Resource112=IDD_CREATE_NODE (English (U.S.))
+Resource112=IDD_SELECT_EVENT (English (U.S.))
 Class80=CNodePropsPolling
+Class81=CDeploymentView
 Resource113=IDD_OBJECT_NODE_POLL (English (U.S.))
 
 [CLS:CConsoleApp]
@@ -2972,3 +2973,10 @@ Filter=D
 LastObject=CNodePropsPolling
 VirtualFilter=idWC
 
+[CLS:CDeploymentView]
+Type=0
+HeaderFile=DeploymentView.h
+ImplementationFile=DeploymentView.cpp
+BaseClass=CMDIChildWnd
+Filter=M
+
index 80ff451..56c44b1 100644 (file)
@@ -15,6 +15,7 @@
 #include "MIBBrowserDlg.h"
 #include "NetSrvPropsGeneral.h"
 #include "NodePropsPolling.h"
+#include "DeploymentView.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -1515,3 +1516,16 @@ void CConsoleApp::WakeUpNode(DWORD dwObjectId)
       m_pMainWnd->MessageBox(_T("Wake-On-LAN magic packet was successfully sent to node"),
                              _T("Information"), MB_ICONINFORMATION | MB_OK);
 }
+
+
+//
+// Deploy package to nodes
+//
+
+void CConsoleApp::DeployPackage(DWORD dwPkgId, DWORD dwNumObjects, DWORD *pdwObjectList)
+{
+       CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
+
+       pFrame->CreateNewChild(
+               RUNTIME_CLASS(CDeploymentView), IDR_PACKAGE_MGR, m_hMDIMenu, m_hMDIAccel);
+}
index e45c825..293be9b 100644 (file)
@@ -185,6 +185,10 @@ SOURCE=.\DebugFrame.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\DeploymentView.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\draw.cpp
 # End Source File
 # Begin Source File
@@ -502,6 +506,10 @@ SOURCE=.\DebugFrame.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\DeploymentView.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\EditActionDlg.h
 # End Source File
 # Begin Source File
index 91ef42f..6b8fe53 100644 (file)
@@ -186,6 +186,7 @@ private:
    DC_EDITOR m_openDCEditors[MAX_DC_EDITORS];
 
 public:
+       void DeployPackage(DWORD dwPkgId, DWORD dwNumObjects, DWORD *pdwObjectList);
        void CreateNetworkService(DWORD dwParent);
        void WakeUpNode(DWORD dwObjectId);
        void CreateTemplateGroup(DWORD dwParent);
index 9c125d4..9386b8f 100644 (file)
@@ -305,7 +305,7 @@ BOOL LIBNETXMS_EXPORTABLE NxGetParameterArg(TCHAR *param, int index, TCHAR *arg,
                case _T('"'):
                   state = 0;     // Normal
                   break;
-               case _T('\\'):        // Escape
+/*               case _T('\\'):        // Escape
                   ptr2++;
                   if ((currIndex == index) && (pos < maxSize - 1))
                      arg[pos++] = *ptr2;
@@ -314,7 +314,7 @@ BOOL LIBNETXMS_EXPORTABLE NxGetParameterArg(TCHAR *param, int index, TCHAR *arg,
                      bResult = FALSE;
                      state = -1;
                   }
-                  break;
+                  break;*/
                case 0:
                   state = -1;    // Finish processing
                   bResult = FALSE;  // Set error flag
@@ -330,7 +330,7 @@ BOOL LIBNETXMS_EXPORTABLE NxGetParameterArg(TCHAR *param, int index, TCHAR *arg,
                case _T('\''):
                   state = 0;     // Normal
                   break;
-               case _T('\\'):        // Escape
+/*               case _T('\\'):        // Escape
                   ptr2++;
                   if ((currIndex == index) && (pos < maxSize - 1))
                      arg[pos++] = *ptr2;
@@ -339,7 +339,7 @@ BOOL LIBNETXMS_EXPORTABLE NxGetParameterArg(TCHAR *param, int index, TCHAR *arg,
                      bResult = FALSE;
                      state = -1;
                   }
-                  break;
+                  break;*/
                case 0:
                   state = -1;    // Finish processing
                   bResult = FALSE;  // Set error flag
index ebc1fc3..990dac4 100644 (file)
@@ -245,26 +245,31 @@ void Interface::StatusPoll(ClientSession *pSession, DWORD dwRqId)
                  m_szName, g_pszStatusName[m_iStatus]);
 
    // Poll interface using different methods
-   if (pNode->Flags() & NF_IS_NATIVE_AGENT)
+   if (m_dwIfType != IFTYPE_NETXMS_NAT_ADAPTER)
    {
-      SendPollerMsg(dwRqId, "      Retrieving interface status from NetXMS agent\r\n");
-      m_iStatus = pNode->GetInterfaceStatusFromAgent(m_dwIfIndex);
-      if (m_iStatus != STATUS_UNKNOWN)
-         bNeedPoll = FALSE;
-   }
+      if (pNode->Flags() & NF_IS_NATIVE_AGENT)
+      {
+         SendPollerMsg(dwRqId, "      Retrieving interface status from NetXMS agent\r\n");
+         m_iStatus = pNode->GetInterfaceStatusFromAgent(m_dwIfIndex);
+         if (m_iStatus != STATUS_UNKNOWN)
+            bNeedPoll = FALSE;
+      }
    
-   if ((pNode->Flags() & NF_IS_SNMP) && bNeedPoll)
-   {
-      SendPollerMsg(dwRqId, "      Retrieving interface status from SNMP agent\r\n");
-      m_iStatus = pNode->GetInterfaceStatusFromSNMP(m_dwIfIndex);
-      if (m_iStatus != STATUS_UNKNOWN)
-         bNeedPoll = FALSE;
+      if ((pNode->Flags() & NF_IS_SNMP) && bNeedPoll)
+      {
+         SendPollerMsg(dwRqId, "      Retrieving interface status from SNMP agent\r\n");
+         m_iStatus = pNode->GetInterfaceStatusFromSNMP(m_dwIfIndex);
+         if (m_iStatus != STATUS_UNKNOWN)
+            bNeedPoll = FALSE;
+      }
    }
    
    if (bNeedPoll)
    {
       // Use ICMP ping as a last option
-      if (m_dwIpAddr != 0)
+      if ((m_dwIpAddr != 0) && 
+           ((!(pNode->Flags() & NF_BEHIND_NAT)) || 
+            (m_dwIfType == IFTYPE_NETXMS_NAT_ADAPTER)))
       {
          SendPollerMsg(dwRqId, "      Starting ICMP ping\r\n");
          dwPingStatus = IcmpPing(htonl(m_dwIpAddr), 3, 1500, NULL);
index 791fe5e..d9ceb7e 100644 (file)
@@ -158,7 +158,9 @@ BOOL NetworkService::CreateFromDB(DWORD dwId)
       m_wProto = (WORD)DBGetFieldULong(hResult, 0, 6);
       m_wPort = (WORD)DBGetFieldULong(hResult, 0, 7);
       m_pszRequest = _tcsdup(CHECK_NULL_EX(DBGetField(hResult, 0, 8)));
+      DecodeSQLString(m_pszRequest);
       m_pszResponce = _tcsdup(CHECK_NULL_EX(DBGetField(hResult, 0, 9)));
+      DecodeSQLString(m_pszResponce);
       m_dwPollerNode = DBGetFieldULong(hResult, 0, 10);
       m_dwImageId = DBGetFieldULong(hResult, 0, 11);
 
index cd08141..f7a547e 100644 (file)
@@ -424,6 +424,26 @@ void Node::NewNodePoll(DWORD dwNetMask)
                                pIfList->pInterfaces[i].dwIndex,
                                pIfList->pInterfaces[i].dwType,
                                pIfList->pInterfaces[i].bMacAddr);
+
+         // Check if address we are using to communicate with node
+         // is configured on one of node's interfaces
+         for(i = 0; i < pIfList->iNumEntries; i++)
+            if (pIfList->pInterfaces[i].dwIpAddr == m_dwIpAddr)
+               break;
+
+         if (i == pIfList->iNumEntries)
+         {
+            char szBuffer[MAX_OBJECT_NAME];
+
+            // Node is behind NAT
+            m_dwFlags |= NF_BEHIND_NAT;
+
+            // Create pseudo interface for NAT
+            ConfigReadStr("NATAdapterName", szBuffer, MAX_OBJECT_NAME, "NetXMS NAT Adapter");
+            CreateNewInterface(m_dwIpAddr, 0, szBuffer,
+                               0x7FFFFFFF, IFTYPE_NETXMS_NAT_ADAPTER);
+         }
+
          DestroyInterfaceList(pIfList);
       }
       else
@@ -875,21 +895,24 @@ void Node::ConfigurationPoll(ClientSession *pSession, DWORD dwRqId)
          {
             Interface *pInterface = (Interface *)m_pChildList[i];
 
-            for(j = 0; j < pIfList->iNumEntries; j++)
-               if ((pIfList->pInterfaces[j].dwIndex == pInterface->IfIndex()) &&
-                   (pIfList->pInterfaces[j].dwIpAddr == pInterface->IpAddr()) &&
-                   (pIfList->pInterfaces[j].dwIpNetMask == pInterface->IpNetMask()))
-                  break;
-            if (j == pIfList->iNumEntries)
+            if (pInterface->IfType() != IFTYPE_NETXMS_NAT_ADAPTER)
             {
-               // No such interface in current configuration, delete it
-               SendPollerMsg(dwRqId, _T("   Interface \"%s\" is no longer exist\r\n"), 
-                             pInterface->Name());
-               PostEvent(EVENT_INTERFACE_DELETED, m_dwId, "dsaa", pInterface->IfIndex(),
-                         pInterface->Name(), pInterface->IpAddr(), pInterface->IpNetMask());
-               DeleteInterface(pInterface);
-               i = 0xFFFFFFFF;   // Restart loop
-               bHasChanges = TRUE;
+               for(j = 0; j < pIfList->iNumEntries; j++)
+                  if ((pIfList->pInterfaces[j].dwIndex == pInterface->IfIndex()) &&
+                      (pIfList->pInterfaces[j].dwIpAddr == pInterface->IpAddr()) &&
+                      (pIfList->pInterfaces[j].dwIpNetMask == pInterface->IpNetMask()))
+                     break;
+               if (j == pIfList->iNumEntries)
+               {
+                  // No such interface in current configuration, delete it
+                  SendPollerMsg(dwRqId, _T("   Interface \"%s\" is no longer exist\r\n"), 
+                                pInterface->Name());
+                  PostEvent(EVENT_INTERFACE_DELETED, m_dwId, "dsaa", pInterface->IfIndex(),
+                            pInterface->Name(), pInterface->IpAddr(), pInterface->IpNetMask());
+                  DeleteInterface(pInterface);
+                  i = 0xFFFFFFFF;   // Restart loop
+                  bHasChanges = TRUE;
+               }
             }
          }
 
@@ -935,6 +958,38 @@ void Node::ConfigurationPoll(ClientSession *pSession, DWORD dwRqId)
          }
       }
 
+      // Check if address we are using to communicate with node
+      // is configured on one of node's interfaces
+      for(i = 0; i < (DWORD)pIfList->iNumEntries; i++)
+         if (pIfList->pInterfaces[i].dwIpAddr == m_dwIpAddr)
+            break;
+
+      if (i == (DWORD)pIfList->iNumEntries)
+      {
+         // Node is behind NAT
+         m_dwFlags |= NF_BEHIND_NAT;
+
+         // Check if we already have NAT interface
+         Lock();
+         for(i = 0; i < m_dwChildCount; i++)
+            if (m_pChildList[i]->Type() == OBJECT_INTERFACE)
+            {
+               if (((Interface *)m_pChildList[i])->IfType() == IFTYPE_NETXMS_NAT_ADAPTER)
+                  break;
+            }
+         Unlock();
+
+         if (i == m_dwChildCount)
+         {
+            char szBuffer[MAX_OBJECT_NAME];
+
+            // Create pseudo interface for NAT
+            ConfigReadStr("NATAdapterName", szBuffer, MAX_OBJECT_NAME, "NetXMS NAT Adapter");
+            CreateNewInterface(m_dwIpAddr, 0, szBuffer,
+                               0x7FFFFFFF, IFTYPE_NETXMS_NAT_ADAPTER);
+         }
+      }
+
       DestroyInterfaceList(pIfList);
    }
    else
@@ -1332,6 +1387,7 @@ int Node::GetInterfaceStatusFromAgent(DWORD dwIndex)
             {
                iStatus = STATUS_UNKNOWN;
             }
+            break;
          default:
             iStatus = STATUS_UNKNOWN;
             break;
index dcbb69e..2ce1f2a 100644 (file)
@@ -288,6 +288,7 @@ public:
 
    DWORD IpNetMask(void) { return m_dwIpNetMask; }
    DWORD IfIndex(void) { return m_dwIfIndex; }
+   DWORD IfType(void) { return m_dwIfType; }
    const BYTE *MacAddr(void) { return m_bMacAddr; }
 
    void StatusPoll(ClientSession *pSession, DWORD dwRqId);
index 0e67e75..4b9cee2 100644 (file)
@@ -74,6 +74,39 @@ static BOOL CreateConfigParam(TCHAR *pszName, TCHAR *pszValue, int iVisible, int
 }
 
 
+//
+// Upgrade from V20 to V21
+//
+
+static BOOL H_UpgradeFromV20(void)
+{
+   DB_RESULT hResult;
+
+   if (!SQLQuery(_T("ALTER TABLE nodes ADD node_flags integer")))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   // Convert "is_xxx" fields into one "node_flags" field
+   hResult = SQLSelect(_T("SELECT id,is_snmp,is_agent,is_bridge,is_router,"
+                          "is_local_mgmt,is_ospf FROM nodes"));
+   if (hResult != NULL)
+   {
+      DBFreeResult(hResult);
+   }
+   else
+   {
+      if (!g_bIgnoreErrors)
+         return FALSE;
+   }
+
+   if (!SQLQuery(_T("UPDATE config SET var_value='21' WHERE var_name='DBFormatVersion'")))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   return TRUE;
+}
+
+
 //
 // Upgrade from V19 to V20
 //
@@ -503,6 +536,7 @@ static struct
    { 17, H_UpgradeFromV17 },
    { 18, H_UpgradeFromV18 },
    { 19, H_UpgradeFromV19 },
+   { 20, H_UpgradeFromV20 },
    { 0, NULL }
 };