avaya drivers restructured, common code moved to separate library
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 13 Apr 2011 15:28:27 +0000 (15:28 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 13 Apr 2011 15:28:27 +0000 (15:28 +0000)
15 files changed:
.gitattributes
doc/internal/event_code_ranges.txt
netxms.sln
src/server/drivers/Makefile.am
src/server/drivers/baystack/baystack.cpp
src/server/drivers/baystack/baystack.h
src/server/drivers/baystack/baystack.vcproj
src/server/drivers/baystack/vlan.cpp [deleted file]
src/server/drivers/ers8000/ers8000.cpp
src/server/drivers/ers8000/ers8000.h
src/server/drivers/ers8000/ers8000.vcproj
src/server/drivers/lib/avaya-ers/avaya-ers.cpp [new file with mode: 0644]
src/server/drivers/lib/avaya-ers/avaya-ers.h [copied from src/server/drivers/baystack/baystack.h with 60% similarity]
src/server/drivers/lib/avaya-ers/avaya-ers.vcproj [new file with mode: 0644]
src/server/drivers/lib/avaya-ers/vlan-if.cpp [moved from src/server/drivers/ers8000/vlan.cpp with 81% similarity]

index d2639dc..25c4289 100644 (file)
@@ -1315,7 +1315,7 @@ src/server/drivers/ers8000/Makefile.am -text
 src/server/drivers/ers8000/ers8000.cpp -text
 src/server/drivers/ers8000/ers8000.h -text
 src/server/drivers/ers8000/ers8000.vcproj -text
-src/server/drivers/ers8000/vlan.cpp -text
+src/server/drivers/lib/avaya-ers/avaya-ers.vcproj -text
 src/server/include/Makefile.am -text
 src/server/libnxsrv/apinfo.cpp -text
 src/server/libnxsrv/libnxsrv.vcproj -text
index 8cc75c5..5776f9c 100644 (file)
@@ -1,10 +1,9 @@
 0 - 499                System events
 500 - 510      Well-known SNMP traps
 4000 - 4999    Predefined threshold violation events
+80000 - 80999   VEDAS
 89000 - 89899   XFS subagent
 89900 - 89999   AVS (ATM Video Surveillance) subsystem
 90000 - 90999  Agilis monitoring subagent
 91000 - 91099   Cortex monitoring subagent
 100000 - ...   User-defined events
-
-80000-80999    Vedas
index b82e7a4..5a008e3 100644 (file)
@@ -442,10 +442,21 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "baystack", "src\server\driv
                {AEB182ED-7F5C-4F5A-BCE1-9A38E98579BA} = {AEB182ED-7F5C-4F5A-BCE1-9A38E98579BA}
                {7DC90EE4-E31C-4F12-8F1E-81F10E9099FC} = {7DC90EE4-E31C-4F12-8F1E-81F10E9099FC}
                {CB89D905-C8BE-4027-B2D8-F96C245E9160} = {CB89D905-C8BE-4027-B2D8-F96C245E9160}
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078} = {DA651576-4E4F-448C-A0A3-9EDD15C81078}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ers8000", "src\server\drivers\ers8000\ers8000.vcproj", "{076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}"
        ProjectSection(ProjectDependencies) = postProject
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078} = {DA651576-4E4F-448C-A0A3-9EDD15C81078}
+               {CB89D905-C8BE-4027-B2D8-F96C245E9160} = {CB89D905-C8BE-4027-B2D8-F96C245E9160}
+               {7DC90EE4-E31C-4F12-8F1E-81F10E9099FC} = {7DC90EE4-E31C-4F12-8F1E-81F10E9099FC}
+               {AEB182ED-7F5C-4F5A-BCE1-9A38E98579BA} = {AEB182ED-7F5C-4F5A-BCE1-9A38E98579BA}
+       EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{D73BB67D-032B-4FB7-AEB8-5795B246A072}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "avaya-ers", "src\server\drivers\lib\avaya-ers\avaya-ers.vcproj", "{DA651576-4E4F-448C-A0A3-9EDD15C81078}"
+       ProjectSection(ProjectDependencies) = postProject
                {CB89D905-C8BE-4027-B2D8-F96C245E9160} = {CB89D905-C8BE-4027-B2D8-F96C245E9160}
                {7DC90EE4-E31C-4F12-8F1E-81F10E9099FC} = {7DC90EE4-E31C-4F12-8F1E-81F10E9099FC}
                {AEB182ED-7F5C-4F5A-BCE1-9A38E98579BA} = {AEB182ED-7F5C-4F5A-BCE1-9A38E98579BA}
@@ -1207,6 +1218,14 @@ Global
                {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Release|Win32.Build.0 = Release|Win32
                {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Release|x64.ActiveCfg = Release|x64
                {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Release|x64.Build.0 = Release|x64
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Win32
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078}.Debug|Win32.ActiveCfg = Debug|Win32
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078}.Debug|Win32.Build.0 = Debug|Win32
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078}.Debug|x64.ActiveCfg = Debug|Win32
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Win32
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078}.Release|Win32.ActiveCfg = Release|Win32
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078}.Release|Win32.Build.0 = Release|Win32
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078}.Release|x64.ActiveCfg = Release|Win32
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
@@ -1294,5 +1313,7 @@ Global
                {D7F709ED-7483-49F0-8B17-ABB705606FEA} = {89B3A66E-5853-4B14-A5E3-9E4C6524BE65}
                {13A91F2E-A17B-4ABA-B5B2-285807BD7832} = {53997B2A-D94C-428C-816D-938C297A1866}
                {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC} = {53997B2A-D94C-428C-816D-938C297A1866}
+               {D73BB67D-032B-4FB7-AEB8-5795B246A072} = {53997B2A-D94C-428C-816D-938C297A1866}
+               {DA651576-4E4F-448C-A0A3-9EDD15C81078} = {D73BB67D-032B-4FB7-AEB8-5795B246A072}
        EndGlobalSection
 EndGlobal
index 28a5ae2..20ecc28 100644 (file)
@@ -8,4 +8,4 @@
 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-SUBDIRS = baystack ers8000
+SUBDIRS = lib baystack ers8000
index a34b109..15f726d 100644 (file)
@@ -92,6 +92,17 @@ void BayStackDriver::analyzeDevice(SNMP_Transport *snmp, const TCHAR *oid, Strin
 }
 
 /**
+ * Get slot size from object's custom attributes. Default implementation always return constant value 64.
+ *
+ * @param attributes object's custom attributes
+ * @return slot size
+ */
+DWORD BayStackDriver::getSlotSize(StringMap *attributes)
+{
+       return attributes->getULong(_T(".baystack.slotSize"), 64);
+}
+
+/**
  * Get list of interfaces for given node
  *
  * @param snmp SNMP transport
@@ -150,7 +161,7 @@ InterfaceList *BayStackDriver::getInterfaces(SNMP_Transport *snmp, StringMap *at
        }
 
        if (attributes->getULong(_T(".baystack.rapidCity.vlan"), 0) > 0)
-               GetVLANInterfaces(snmp, ifList);
+               getVlanInterfaces(snmp, ifList);
 
        DWORD mgmtIpAddr, mgmtNetMask;
        if ((SnmpGet(snmp->getSnmpVersion(), snmp, _T(".1.3.6.1.4.1.45.1.6.4.2.2.1.2.1"), NULL, 0, &mgmtIpAddr, sizeof(DWORD), 0) == SNMP_ERR_SUCCESS) &&
index 9760bd9..17a1f65 100644 (file)
 #define _baystack_h_
 
 #include <nddrv.h>
+#include "../lib/avaya-ers/avaya-ers.h"
 
 
 /**
  * Driver's class
  */
-class BayStackDriver : public NetworkDeviceDriver
+class BayStackDriver : public AvayaERSDriver
 {
+protected:
+       virtual DWORD getSlotSize(StringMap *attributes);
+
 public:
        virtual const TCHAR *getName();
        virtual const TCHAR *getVersion();
@@ -39,12 +43,6 @@ public:
        virtual bool isDeviceSupported(const TCHAR *oid);
        virtual void analyzeDevice(SNMP_Transport *snmp, const TCHAR *oid, StringMap *attributes);
        virtual InterfaceList *getInterfaces(SNMP_Transport *snmp, StringMap *attributes, int useAliases, bool useIfXTable);
-       virtual VlanList *getVlans(SNMP_Transport *snmp, StringMap *attributes);
 };
 
-/**
- * Functions
- */
-void GetVLANInterfaces(SNMP_Transport *pTransport, InterfaceList *pIfList);
-
 #endif
index c611530..248f96c 100644 (file)
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
-                       IntermediateDirectory="$(ConfigurationName)"\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="1"\r
-                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\include;..\..\..\..\include"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BAYSTACK_EXPORTS"\r
-                               RuntimeLibrary="2"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BAYSTACK_EXPORTS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
                                Detect64BitPortabilityProblems="false"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                OutputFile="$(OutDir)\$(ProjectName).ndd"\r
-                               LinkIncremental="1"\r
+                               LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
+                               TargetMachine="17"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Debug|x64"\r
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\include;..\..\..\..\include"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BAYSTACK_EXPORTS"\r
-                               MinimalRebuild="true"\r
-                               BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="3"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BAYSTACK_EXPORTS"\r
+                               RuntimeLibrary="2"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
                                Detect64BitPortabilityProblems="false"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                OutputFile="$(OutDir)\$(ProjectName).ndd"\r
-                               LinkIncremental="2"\r
+                               LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               TargetMachine="17"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                                RelativePath=".\baystack.cpp"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\vlan.cpp"\r
-                               >\r
-                       </File>\r
                </Filter>\r
                <Filter\r
                        Name="Header Files"\r
diff --git a/src/server/drivers/baystack/vlan.cpp b/src/server/drivers/baystack/vlan.cpp
deleted file mode 100644 (file)
index 3f20433..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/* 
-** NetXMS - Network Management System
-** Driver for Avaya ERS switches (except ERS 8xxx) (former Nortel/Bay Networks BayStack)
-** Copyright (C) 2003-2011 Victor Kirhenshtein
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** File: vlan.cpp
-**
-**/
-
-#include "baystack.h"
-
-
-//
-// VLAN information structure
-//
-
-struct VLAN_INFO
-{
-   TCHAR szName[MAX_OBJECT_NAME];
-   DWORD dwVlanId;
-   DWORD dwIfIndex;
-   BYTE bMacAddr[MAC_ADDR_LENGTH];
-};
-
-struct VLAN_LIST
-{
-   DWORD dwNumVlans;
-   VLAN_INFO *pList;
-};
-
-
-/**
- * Handler for VLAN enumeration on Avaya ERS
- */
-static DWORD HandlerVlanIfList(DWORD dwVersion, SNMP_Variable *pVar,
-                             SNMP_Transport *pTransport, void *pArg)
-{
-   DWORD dwIndex, oidName[MAX_OID_LEN], dwNameLen, dwResult;
-   VLAN_LIST *pVlanList = (VLAN_LIST *)pArg;
-   BYTE szBuffer[256];
-
-   dwNameLen = pVar->GetName()->Length();
-
-   // Extend VLAN list and set ID of new VLAN
-   dwIndex = pVlanList->dwNumVlans;
-   pVlanList->dwNumVlans++;
-   pVlanList->pList = (VLAN_INFO *)realloc(pVlanList->pList, sizeof(VLAN_INFO) * pVlanList->dwNumVlans);
-   pVlanList->pList[dwIndex].dwVlanId = pVar->GetValueAsUInt();
-
-   // Get VLAN name
-   memcpy(oidName, pVar->GetName()->GetValue(), dwNameLen * sizeof(DWORD));
-   oidName[dwNameLen - 2] = 2;
-   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, 
-                      pVlanList->pList[dwIndex].szName, MAX_OBJECT_NAME, 0);
-   if (dwResult != SNMP_ERR_SUCCESS)
-      return dwResult;
-
-   // Get VLAN interface index
-   oidName[dwNameLen - 2] = 6;
-   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, 
-                      &pVlanList->pList[dwIndex].dwIfIndex, sizeof(DWORD), 0);
-   if (dwResult != SNMP_ERR_SUCCESS)
-      return dwResult;
-
-   // Get VLAN MAC address
-   oidName[dwNameLen - 2] = 19;
-   memset(pVlanList->pList[dwIndex].bMacAddr, 0, MAC_ADDR_LENGTH);
-   memset(szBuffer, 0, MAC_ADDR_LENGTH);
-   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, szBuffer, 256, SG_RAW_RESULT);
-   if (dwResult == SNMP_ERR_SUCCESS)
-      memcpy(pVlanList->pList[dwIndex].bMacAddr, szBuffer, MAC_ADDR_LENGTH);
-   return dwResult;
-}
-
-/**
- * Handler for VLAN enumeration on Passport
- */
-static DWORD HandlerPassportIfList(DWORD dwVersion, SNMP_Variable *pVar,
-                                  SNMP_Transport *pTransport, void *pArg)
-{
-   InterfaceList *pIfList = (InterfaceList *)pArg;
-   VLAN_LIST *pVlanList = (VLAN_LIST *)pIfList->getData();
-   DWORD oidName[MAX_OID_LEN], dwVlanIndex, dwIfIndex, dwNameLen, dwResult;
-
-   dwIfIndex = pVar->GetValueAsUInt();
-   for(dwVlanIndex = 0; dwVlanIndex < pVlanList->dwNumVlans; dwVlanIndex++)
-      if (pVlanList->pList[dwVlanIndex].dwIfIndex == dwIfIndex)
-         break;
-
-   // Create new interface only if we have VLAN with same interface index
-   if (dwVlanIndex < pVlanList->dwNumVlans)
-   {
-               NX_INTERFACE_INFO iface;
-
-               memset(&iface, 0, sizeof(NX_INTERFACE_INFO));
-      iface.dwIndex = dwIfIndex;
-      _tcscpy(iface.szName, pVlanList->pList[dwVlanIndex].szName);
-      iface.dwType = IFTYPE_OTHER;
-      memcpy(iface.bMacAddr, pVlanList->pList[dwVlanIndex].bMacAddr, MAC_ADDR_LENGTH);
-      
-      dwNameLen = pVar->GetName()->Length();
-
-      // Get IP address
-      memcpy(oidName, pVar->GetName()->GetValue(), dwNameLen * sizeof(DWORD));
-      oidName[dwNameLen - 6] = 2;
-      dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen,
-                         &iface.dwIpAddr, sizeof(DWORD), 0);
-
-      if (dwResult == SNMP_ERR_SUCCESS)
-      {
-         // Get netmask
-         oidName[dwNameLen - 6] = 3;
-         dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen,
-                            &iface.dwIpNetMask, sizeof(DWORD), 0);
-      }
-
-               pIfList->add(&iface);
-   }
-   else
-   {
-      dwResult = SNMP_ERR_SUCCESS;  // Ignore interfaces without matching VLANs
-   }
-   return dwResult;
-}
-
-/**
- * Get list of VLAN interfaces from Avaya ERS switch
- *
- * @param pTransport SNMP transport
- * @param pIfList interface list to be populated
- */
-void GetVLANInterfaces(SNMP_Transport *pTransport, InterfaceList *pIfList)
-{
-   VLAN_LIST vlanList;
-
-   // Get VLAN list
-   memset(&vlanList, 0, sizeof(VLAN_LIST));
-   SnmpEnumerate(pTransport->getSnmpVersion(), pTransport, _T(".1.3.6.1.4.1.2272.1.3.2.1.1"), HandlerVlanIfList, &vlanList, FALSE);
-
-   // Get interfaces
-   pIfList->setData(&vlanList);
-   SnmpEnumerate(pTransport->getSnmpVersion(), pTransport, _T(".1.3.6.1.4.1.2272.1.8.2.1.1"), 
-                 HandlerPassportIfList, pIfList, FALSE);
-   safe_free(vlanList.pList);
-}
-
-/**
- * Handler for VLAN enumeration on Avaya ERS
- */
-static DWORD HandlerVlanList(DWORD dwVersion, SNMP_Variable *pVar, SNMP_Transport *pTransport, void *pArg)
-{
-   DWORD oidName[MAX_OID_LEN], dwResult;
-   VlanList *vlanList = (VlanList *)pArg;
-       StringMap *attributes = (StringMap *)vlanList->getData();
-
-   DWORD dwNameLen = pVar->GetName()->Length();
-       VlanInfo *vlan = new VlanInfo(pVar->GetValueAsInt());
-
-   // Get VLAN name
-   memcpy(oidName, pVar->GetName()->GetValue(), dwNameLen * sizeof(DWORD));
-   oidName[dwNameLen - 2] = 2;
-   TCHAR buffer[256];
-       dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, buffer, 256, SG_STRING_RESULT);
-   if (dwResult != SNMP_ERR_SUCCESS)
-       {
-               delete vlan;
-      return dwResult;
-       }
-       vlan->setName(buffer);
-
-   // Get member ports
-       // From RapidCity MIB:
-       //   The string is 32 octets long, for a total of 256 bits. Each bit 
-       //   corresponds to a port, as represented by its ifIndex value . When a 
-       //   bit has the value one(1), the corresponding port is a member of the 
-       //   set. When a bit has the value zero(0), the corresponding port is not 
-       //   a member of the set. The encoding is such that the most significant 
-       //   bit of octet #1 corresponds to ifIndex 0, while the least significant 
-       //   bit of octet #32 corresponds to ifIndex 255." 
-       // Note: on newer devices port list can be longer
-   oidName[dwNameLen - 2] = 12;
-       BYTE portMask[256];
-       memset(portMask, 0, sizeof(portMask));
-   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, portMask, 256, SG_RAW_RESULT);
-   if (dwResult != SNMP_ERR_SUCCESS)
-       {
-               delete vlan;
-      return dwResult;
-       }
-
-       DWORD slotSize = attributes->getULong(_T(".baystack.slotSize"), 64);
-       DWORD ifIndex = 0;
-
-       for(int i = 0; i < 256; i++)
-       {
-               BYTE mask = 0x80;
-               while(mask > 0)
-               {
-                       if (portMask[i] & mask)
-                       {
-                               DWORD slot = ifIndex / slotSize + 1;
-                               DWORD port = ifIndex % slotSize;
-                               vlan->add(slot, port);
-                       }
-                       mask >>= 1;
-                       ifIndex++;
-               }
-       }
-
-       vlanList->add(vlan);
-   return SNMP_ERR_SUCCESS;
-}
-
-/**
- * Get VLANs 
- */
-VlanList *BayStackDriver::getVlans(SNMP_Transport *snmp, StringMap *attributes)
-{
-       VlanList *list = new VlanList();
-       list->setData(attributes);
-       if (SnmpEnumerate(snmp->getSnmpVersion(), snmp, _T(".1.3.6.1.4.1.2272.1.3.2.1.1"), HandlerVlanList, list, FALSE) != SNMP_ERR_SUCCESS)
-       {
-               delete_and_null(list);
-       }
-       return list;
-}
index 6e082d8..0a2c763 100644 (file)
@@ -82,7 +82,7 @@ InterfaceList *PassportDriver::getInterfaces(SNMP_Transport *snmp, StringMap *at
                }\r
        }\r
 \r
-       GetVLANInterfaces(snmp, ifList);\r
+       getVlanInterfaces(snmp, ifList);\r
 \r
        return ifList;\r
 }\r
index b3cee5e..e92c75c 100644 (file)
 #define _ers8000_h_\r
 \r
 #include <nddrv.h>\r
+#include "../lib/avaya-ers/avaya-ers.h"\r
 \r
 \r
 /**\r
  * Driver's class\r
  */\r
-class PassportDriver : public NetworkDeviceDriver\r
+class PassportDriver : public AvayaERSDriver\r
 {\r
 public:\r
        virtual const TCHAR *getName();\r
@@ -40,9 +41,4 @@ public:
        virtual InterfaceList *getInterfaces(SNMP_Transport *snmp, StringMap *attributes, int useAliases, bool useIfXTable);\r
 };\r
 \r
-/**\r
- * Functions\r
- */\r
-void GetVLANInterfaces(SNMP_Transport *pTransport, InterfaceList *pIfList);\r
-\r
 #endif\r
index 8009e0b..465be80 100644 (file)
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
-                       IntermediateDirectory="$(ConfigurationName)"\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="1"\r
-                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\include;..\..\..\..\include"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;ERS8000_EXPORTS"\r
-                               RuntimeLibrary="2"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;ERS8000_EXPORTS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
                                Detect64BitPortabilityProblems="false"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                OutputFile="$(OutDir)\$(ProjectName).ndd"\r
-                               LinkIncremental="1"\r
+                               LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
+                               TargetMachine="17"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Debug|x64"\r
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\include;..\..\..\..\include"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;ERS8000_EXPORTS"\r
-                               MinimalRebuild="true"\r
-                               BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="3"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;ERS8000_EXPORTS"\r
+                               RuntimeLibrary="2"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
                                Detect64BitPortabilityProblems="false"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                OutputFile="$(OutDir)\$(ProjectName).ndd"\r
-                               LinkIncremental="2"\r
+                               LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               TargetMachine="17"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                                RelativePath=".\ers8000.cpp"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\vlan.cpp"\r
-                               >\r
-                       </File>\r
                </Filter>\r
                <Filter\r
                        Name="Header Files"\r
diff --git a/src/server/drivers/lib/avaya-ers/avaya-ers.cpp b/src/server/drivers/lib/avaya-ers/avaya-ers.cpp
new file mode 100644 (file)
index 0000000..ef39715
--- /dev/null
@@ -0,0 +1,131 @@
+/* 
+** NetXMS - Network Management System
+** Generic driver for Avaya ERS switches (former Nortel)
+** Copyright (C) 2003-2011 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: avaya-ers.cpp
+**
+**/
+
+#include "avaya-ers.h"
+
+
+/**
+ * Get slot size from object's custom attributes. Default implementation always return constant value 64.
+ *
+ * @param attributes object's custom attributes
+ * @return slot size
+ */
+DWORD AvayaERSDriver::getSlotSize(StringMap *attributes)
+{
+       return 64;
+}
+
+/**
+ * Handler for VLAN enumeration on Avaya ERS
+ */
+static DWORD HandlerVlanList(DWORD dwVersion, SNMP_Variable *pVar, SNMP_Transport *pTransport, void *pArg)
+{
+   DWORD oidName[MAX_OID_LEN], dwResult;
+   VlanList *vlanList = (VlanList *)pArg;
+
+   DWORD dwNameLen = pVar->GetName()->Length();
+       VlanInfo *vlan = new VlanInfo(pVar->GetValueAsInt());
+
+   // Get VLAN name
+   memcpy(oidName, pVar->GetName()->GetValue(), dwNameLen * sizeof(DWORD));
+   oidName[dwNameLen - 2] = 2;
+   TCHAR buffer[256];
+       dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, buffer, 256, SG_STRING_RESULT);
+   if (dwResult != SNMP_ERR_SUCCESS)
+       {
+               delete vlan;
+      return dwResult;
+       }
+       vlan->setName(buffer);
+
+   // Get member ports
+       // From RapidCity MIB:
+       //   The string is 32 octets long, for a total of 256 bits. Each bit 
+       //   corresponds to a port, as represented by its ifIndex value . When a 
+       //   bit has the value one(1), the corresponding port is a member of the 
+       //   set. When a bit has the value zero(0), the corresponding port is not 
+       //   a member of the set. The encoding is such that the most significant 
+       //   bit of octet #1 corresponds to ifIndex 0, while the least significant 
+       //   bit of octet #32 corresponds to ifIndex 255." 
+       // Note: on newer devices port list can be longer
+   oidName[dwNameLen - 2] = 12;
+       BYTE portMask[256];
+       memset(portMask, 0, sizeof(portMask));
+   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, portMask, 256, SG_RAW_RESULT);
+   if (dwResult != SNMP_ERR_SUCCESS)
+       {
+               delete vlan;
+      return dwResult;
+       }
+
+       DWORD slotSize = CAST_FROM_POINTER(vlanList->getData(), DWORD);
+       DWORD ifIndex = 0;
+
+       for(int i = 0; i < 256; i++)
+       {
+               BYTE mask = 0x80;
+               while(mask > 0)
+               {
+                       if (portMask[i] & mask)
+                       {
+                               DWORD slot = ifIndex / slotSize + 1;
+                               DWORD port = ifIndex % slotSize;
+                               vlan->add(slot, port);
+                       }
+                       mask >>= 1;
+                       ifIndex++;
+               }
+       }
+
+       vlanList->add(vlan);
+   return SNMP_ERR_SUCCESS;
+}
+
+/**
+ * Get VLANs 
+ */
+VlanList *AvayaERSDriver::getVlans(SNMP_Transport *snmp, StringMap *attributes)
+{
+       VlanList *list = new VlanList();
+       DWORD slotSize = getSlotSize(attributes);
+       list->setData(CAST_TO_POINTER(slotSize, void *));
+       if (SnmpEnumerate(snmp->getSnmpVersion(), snmp, _T(".1.3.6.1.4.1.2272.1.3.2.1.1"), HandlerVlanList, list, FALSE) != SNMP_ERR_SUCCESS)
+       {
+               delete_and_null(list);
+       }
+       return list;
+}
+
+/**
+ * DLL entry point
+ */
+#ifdef _WIN32
+
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
+{
+       if (dwReason == DLL_PROCESS_ATTACH)
+               DisableThreadLibraryCalls(hInstance);
+       return TRUE;
+}
+
+#endif
similarity index 60%
copy from src/server/drivers/baystack/baystack.h
copy to src/server/drivers/lib/avaya-ers/avaya-ers.h
index 9760bd9..dcca94b 100644 (file)
@@ -1,6 +1,6 @@
 /* 
 ** NetXMS - Network Management System
-** Driver for Avaya ERS 8xxx switches (former Nortel/Bay Networks Passport)
+** Generic driver for Avaya ERS switches (former Nortel)
 ** Copyright (C) 2003-2011 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **
-** File: baystack.h
+** File: avaya-ers.h
 **
 **/
 
-#ifndef _baystack_h_
-#define _baystack_h_
+#ifndef _avaya_ers_h_
+#define _avaya_ers_h_
 
 #include <nddrv.h>
 
+#ifdef _WIN32
+#ifdef AVAYAERS_EXPORTS
+#define AVAYA_ERS_EXPORTABLE __declspec(dllexport)
+#else
+#define AVAYA_ERS_EXPORTABLE __declspec(dllimport)
+#endif
+#else
+#define AVAYA_ERS_EXPORTABLE
+#endif
+
 
 /**
  * Driver's class
  */
-class BayStackDriver : public NetworkDeviceDriver
+class AVAYA_ERS_EXPORTABLE AvayaERSDriver : public NetworkDeviceDriver
 {
-public:
-       virtual const TCHAR *getName();
-       virtual const TCHAR *getVersion();
+protected:
+       virtual DWORD getSlotSize(StringMap *attributes);
+
+       void getVlanInterfaces(SNMP_Transport *pTransport, InterfaceList *pIfList);
 
-       virtual bool isDeviceSupported(const TCHAR *oid);
-       virtual void analyzeDevice(SNMP_Transport *snmp, const TCHAR *oid, StringMap *attributes);
-       virtual InterfaceList *getInterfaces(SNMP_Transport *snmp, StringMap *attributes, int useAliases, bool useIfXTable);
+public:
        virtual VlanList *getVlans(SNMP_Transport *snmp, StringMap *attributes);
 };
 
-/**
- * Functions
- */
-void GetVLANInterfaces(SNMP_Transport *pTransport, InterfaceList *pIfList);
-
 #endif
diff --git a/src/server/drivers/lib/avaya-ers/avaya-ers.vcproj b/src/server/drivers/lib/avaya-ers/avaya-ers.vcproj
new file mode 100644 (file)
index 0000000..c3ac60c
--- /dev/null
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="avaya-ers"\r
+       ProjectGUID="{DA651576-4E4F-448C-A0A3-9EDD15C81078}"\r
+       RootNamespace="avayaers"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       CharacterSet="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\..\include"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;AVAYAERS_EXPORTS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\..\include"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;AVAYAERS_EXPORTS"\r
+                               RuntimeLibrary="2"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="2"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\avaya-ers.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\vlan-if.cpp"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\avaya-ers.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
similarity index 81%
rename from src/server/drivers/ers8000/vlan.cpp
rename to src/server/drivers/lib/avaya-ers/vlan-if.cpp
index 7a903cc..df8de0c 100644 (file)
-/* \r
-** NetXMS - Network Management System\r
-** Driver for Avaya ERS 8xxx switches (former Nortel/Bay Networks Passport)\r
-** Copyright (C) 2003-2011 Victor Kirhenshtein\r
-**\r
-** This program is free software; you can redistribute it and/or modify\r
-** it under the terms of the GNU General Public License as published by\r
-** the Free Software Foundation; either version 2 of the License, or\r
-** (at your option) any later version.\r
-**\r
-** This program is distributed in the hope that it will be useful,\r
-** but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-** GNU General Public License for more details.\r
-**\r
-** You should have received a copy of the GNU General Public License\r
-** along with this program; if not, write to the Free Software\r
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
-**\r
-** File: vlan.cpp\r
-**\r
-**/\r
-\r
-#include "ers8000.h"\r
-\r
-\r
-//\r
-// VLAN information structure\r
-//\r
-\r
-struct VLAN_INFO\r
-{\r
-   TCHAR szName[MAX_OBJECT_NAME];\r
-   DWORD dwVlanId;\r
-   DWORD dwIfIndex;\r
-   BYTE bMacAddr[MAC_ADDR_LENGTH];\r
-};\r
-\r
-struct VLAN_LIST\r
-{\r
-   DWORD dwNumVlans;\r
-   VLAN_INFO *pList;\r
-};\r
-\r
-\r
-/**\r
- * Handler for VLAN enumeration on Passport\r
- */\r
-static DWORD HandlerVlanList(DWORD dwVersion, SNMP_Variable *pVar,\r
-                             SNMP_Transport *pTransport, void *pArg)\r
-{\r
-   DWORD dwIndex, oidName[MAX_OID_LEN], dwNameLen, dwResult;\r
-   VLAN_LIST *pVlanList = (VLAN_LIST *)pArg;\r
-   BYTE szBuffer[256];\r
-\r
-   dwNameLen = pVar->GetName()->Length();\r
-\r
-   // Extend VLAN list and set ID of new VLAN\r
-   dwIndex = pVlanList->dwNumVlans;\r
-   pVlanList->dwNumVlans++;\r
-   pVlanList->pList = (VLAN_INFO *)realloc(pVlanList->pList, sizeof(VLAN_INFO) * pVlanList->dwNumVlans);\r
-   pVlanList->pList[dwIndex].dwVlanId = pVar->GetValueAsUInt();\r
-\r
-   // Get VLAN name\r
-   memcpy(oidName, pVar->GetName()->GetValue(), dwNameLen * sizeof(DWORD));\r
-   oidName[dwNameLen - 2] = 2;\r
-   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, \r
-                      pVlanList->pList[dwIndex].szName, MAX_OBJECT_NAME, 0);\r
-   if (dwResult != SNMP_ERR_SUCCESS)\r
-      return dwResult;\r
-\r
-   // Get VLAN interface index\r
-   oidName[dwNameLen - 2] = 6;\r
-   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, \r
-                      &pVlanList->pList[dwIndex].dwIfIndex, sizeof(DWORD), 0);\r
-   if (dwResult != SNMP_ERR_SUCCESS)\r
-      return dwResult;\r
-\r
-   // Get VLAN MAC address\r
-   oidName[dwNameLen - 2] = 19;\r
-   memset(pVlanList->pList[dwIndex].bMacAddr, 0, MAC_ADDR_LENGTH);\r
-   memset(szBuffer, 0, MAC_ADDR_LENGTH);\r
-   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, szBuffer, 256, SG_RAW_RESULT);\r
-   if (dwResult == SNMP_ERR_SUCCESS)\r
-      memcpy(pVlanList->pList[dwIndex].bMacAddr, szBuffer, MAC_ADDR_LENGTH);\r
-   return dwResult;\r
-}\r
-\r
-/**\r
- * Handler for VLAN enumeration on Passport\r
- */\r
-static DWORD HandlerPassportIfList(DWORD dwVersion, SNMP_Variable *pVar,\r
-                                  SNMP_Transport *pTransport, void *pArg)\r
-{\r
-   InterfaceList *pIfList = (InterfaceList *)pArg;\r
-   VLAN_LIST *pVlanList = (VLAN_LIST *)pIfList->getData();\r
-   DWORD oidName[MAX_OID_LEN], dwVlanIndex, dwIfIndex, dwNameLen, dwResult;\r
-\r
-   dwIfIndex = pVar->GetValueAsUInt();\r
-   for(dwVlanIndex = 0; dwVlanIndex < pVlanList->dwNumVlans; dwVlanIndex++)\r
-      if (pVlanList->pList[dwVlanIndex].dwIfIndex == dwIfIndex)\r
-         break;\r
-\r
-   // Create new interface only if we have VLAN with same interface index\r
-   if (dwVlanIndex < pVlanList->dwNumVlans)\r
-   {\r
-               NX_INTERFACE_INFO iface;\r
-\r
-               memset(&iface, 0, sizeof(NX_INTERFACE_INFO));\r
-      iface.dwIndex = dwIfIndex;\r
-      _tcscpy(iface.szName, pVlanList->pList[dwVlanIndex].szName);\r
-      iface.dwType = IFTYPE_OTHER;\r
-      memcpy(iface.bMacAddr, pVlanList->pList[dwVlanIndex].bMacAddr, MAC_ADDR_LENGTH);\r
-      \r
-      dwNameLen = pVar->GetName()->Length();\r
-\r
-      // Get IP address\r
-      memcpy(oidName, pVar->GetName()->GetValue(), dwNameLen * sizeof(DWORD));\r
-      oidName[dwNameLen - 6] = 2;\r
-      dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen,\r
-                         &iface.dwIpAddr, sizeof(DWORD), 0);\r
-\r
-      if (dwResult == SNMP_ERR_SUCCESS)\r
-      {\r
-         // Get netmask\r
-         oidName[dwNameLen - 6] = 3;\r
-         dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen,\r
-                            &iface.dwIpNetMask, sizeof(DWORD), 0);\r
-      }\r
-\r
-               pIfList->add(&iface);\r
-   }\r
-   else\r
-   {\r
-      dwResult = SNMP_ERR_SUCCESS;  // Ignore interfaces without matching VLANs\r
-   }\r
-   return dwResult;\r
-}\r
-\r
-/**\r
- * Get list of VLAN interfaces from Nortel Passport 8000/Accelar switch\r
- *\r
- * @param pTransport SNMP transport\r
- * @param pIfList interface list to be populated\r
- */\r
-void GetVLANInterfaces(SNMP_Transport *pTransport, InterfaceList *pIfList)\r
-{\r
-   VLAN_LIST vlanList;\r
-\r
-   // Get VLAN list\r
-   memset(&vlanList, 0, sizeof(VLAN_LIST));\r
-   SnmpEnumerate(pTransport->getSnmpVersion(), pTransport, _T(".1.3.6.1.4.1.2272.1.3.2.1.1"), HandlerVlanList, &vlanList, FALSE);\r
-\r
-   // Get interfaces\r
-   pIfList->setData(&vlanList);\r
-   SnmpEnumerate(pTransport->getSnmpVersion(), pTransport, _T(".1.3.6.1.4.1.2272.1.8.2.1.1"), \r
-                 HandlerPassportIfList, pIfList, FALSE);\r
-   safe_free(vlanList.pList);\r
-}\r
+/* 
+** NetXMS - Network Management System
+** Generic driver for Avaya ERS switches (former Nortel)
+** Copyright (C) 2003-2011 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: vlan-if.cpp
+**
+**/
+
+#include "avaya-ers.h"
+
+
+//
+// VLAN information structure
+//
+
+struct VLAN_INFO
+{
+   TCHAR szName[MAX_OBJECT_NAME];
+   DWORD dwVlanId;
+   DWORD dwIfIndex;
+   BYTE bMacAddr[MAC_ADDR_LENGTH];
+};
+
+struct VLAN_LIST
+{
+   DWORD dwNumVlans;
+   VLAN_INFO *pList;
+};
+
+
+/**
+ * Handler for VLAN enumeration on Avaya ERS
+ */
+static DWORD HandlerVlanIfList(DWORD dwVersion, SNMP_Variable *pVar, SNMP_Transport *pTransport, void *pArg)
+{
+   DWORD dwIndex, oidName[MAX_OID_LEN], dwNameLen, dwResult;
+   VLAN_LIST *pVlanList = (VLAN_LIST *)pArg;
+   BYTE szBuffer[256];
+
+   dwNameLen = pVar->GetName()->Length();
+
+   // Extend VLAN list and set ID of new VLAN
+   dwIndex = pVlanList->dwNumVlans;
+   pVlanList->dwNumVlans++;
+   pVlanList->pList = (VLAN_INFO *)realloc(pVlanList->pList, sizeof(VLAN_INFO) * pVlanList->dwNumVlans);
+   pVlanList->pList[dwIndex].dwVlanId = pVar->GetValueAsUInt();
+
+   // Get VLAN name
+   memcpy(oidName, pVar->GetName()->GetValue(), dwNameLen * sizeof(DWORD));
+   oidName[dwNameLen - 2] = 2;
+   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, 
+                      pVlanList->pList[dwIndex].szName, MAX_OBJECT_NAME, 0);
+   if (dwResult != SNMP_ERR_SUCCESS)
+      return dwResult;
+
+   // Get VLAN interface index
+   oidName[dwNameLen - 2] = 6;
+   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, 
+                      &pVlanList->pList[dwIndex].dwIfIndex, sizeof(DWORD), 0);
+   if (dwResult != SNMP_ERR_SUCCESS)
+      return dwResult;
+
+   // Get VLAN MAC address
+   oidName[dwNameLen - 2] = 19;
+   memset(pVlanList->pList[dwIndex].bMacAddr, 0, MAC_ADDR_LENGTH);
+   memset(szBuffer, 0, MAC_ADDR_LENGTH);
+   dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, szBuffer, 256, SG_RAW_RESULT);
+   if (dwResult == SNMP_ERR_SUCCESS)
+      memcpy(pVlanList->pList[dwIndex].bMacAddr, szBuffer, MAC_ADDR_LENGTH);
+   return dwResult;
+}
+
+/**
+ * Handler for VLAN enumeration
+ */
+static DWORD HandlerRapidCityIfList(DWORD dwVersion, SNMP_Variable *pVar, SNMP_Transport *pTransport, void *pArg)
+{
+   InterfaceList *pIfList = (InterfaceList *)pArg;
+   VLAN_LIST *pVlanList = (VLAN_LIST *)pIfList->getData();
+   DWORD oidName[MAX_OID_LEN], dwVlanIndex, dwIfIndex, dwNameLen, dwResult;
+
+   dwIfIndex = pVar->GetValueAsUInt();
+   for(dwVlanIndex = 0; dwVlanIndex < pVlanList->dwNumVlans; dwVlanIndex++)
+      if (pVlanList->pList[dwVlanIndex].dwIfIndex == dwIfIndex)
+         break;
+
+   // Create new interface only if we have VLAN with same interface index
+   if (dwVlanIndex < pVlanList->dwNumVlans)
+   {
+               NX_INTERFACE_INFO iface;
+
+               memset(&iface, 0, sizeof(NX_INTERFACE_INFO));
+      iface.dwIndex = dwIfIndex;
+      _tcscpy(iface.szName, pVlanList->pList[dwVlanIndex].szName);
+      iface.dwType = IFTYPE_OTHER;
+      memcpy(iface.bMacAddr, pVlanList->pList[dwVlanIndex].bMacAddr, MAC_ADDR_LENGTH);
+      
+      dwNameLen = pVar->GetName()->Length();
+
+      // Get IP address
+      memcpy(oidName, pVar->GetName()->GetValue(), dwNameLen * sizeof(DWORD));
+      oidName[dwNameLen - 6] = 2;
+      dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen, &iface.dwIpAddr, sizeof(DWORD), 0);
+
+      if (dwResult == SNMP_ERR_SUCCESS)
+      {
+         // Get netmask
+         oidName[dwNameLen - 6] = 3;
+         dwResult = SnmpGet(dwVersion, pTransport, NULL, oidName, dwNameLen,
+                            &iface.dwIpNetMask, sizeof(DWORD), 0);
+      }
+
+               pIfList->add(&iface);
+   }
+   else
+   {
+      dwResult = SNMP_ERR_SUCCESS;  // Ignore interfaces without matching VLANs
+   }
+   return dwResult;
+}
+
+/**
+ * Get list of VLAN interfaces from Avaya ERS switch
+ *
+ * @param pTransport SNMP transport
+ * @param pIfList interface list to be populated
+ */
+void AvayaERSDriver::getVlanInterfaces(SNMP_Transport *pTransport, InterfaceList *pIfList)
+{
+   VLAN_LIST vlanList;
+
+   // Get VLAN list
+   memset(&vlanList, 0, sizeof(VLAN_LIST));
+   SnmpEnumerate(pTransport->getSnmpVersion(), pTransport, _T(".1.3.6.1.4.1.2272.1.3.2.1.1"), HandlerVlanIfList, &vlanList, FALSE);
+
+   // Get interfaces
+   pIfList->setData(&vlanList);
+   SnmpEnumerate(pTransport->getSnmpVersion(), pTransport, _T(".1.3.6.1.4.1.2272.1.8.2.1.1"), HandlerRapidCityIfList, pIfList, FALSE);
+   safe_free(vlanList.pList);
+}