some vendor-specific code moved to device drivers; dropped "node type" attribute...
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 24 Mar 2011 22:35:06 +0000 (22:35 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 24 Mar 2011 22:35:06 +0000 (22:35 +0000)
33 files changed:
.gitattributes
doc/internal/db_format_change.txt
include/Makefile.am
include/netxmsdb.h
include/nms_common.h
include/nms_util.h
include/nxsnmp.h
netxms.sln
sql/schema.in
sql/setup.in
src/libnetxms/strmap.cpp
src/server/core/Makefile.am
src/server/core/main.cpp
src/server/core/node.cpp
src/server/core/nxcore.vcproj
src/server/core/snmp.cpp
src/server/drivers/baystack/baystack.cpp
src/server/drivers/baystack/baystack.vcproj
src/server/drivers/ers8000/ers8000.cpp [new file with mode: 0644]
src/server/drivers/ers8000/ers8000.h [moved from include/nxnt.h with 54% similarity]
src/server/drivers/ers8000/ers8000.vcproj [copied from src/server/drivers/baystack/baystack.vcproj with 87% similarity]
src/server/drivers/ers8000/vlan.cpp [moved from src/server/core/nortel.cpp with 83% similarity]
src/server/include/nddrv.h
src/server/include/nms_core.h
src/server/include/nms_objects.h
src/server/include/nxsrvapi.h
src/server/libnxsrv/Makefile.am
src/server/libnxsrv/libnxsrv.vcproj
src/server/libnxsrv/main.cpp
src/server/libnxsrv/ndd.cpp [new file with mode: 0644]
src/server/libnxsrv/snmp.cpp [new file with mode: 0644]
src/server/tools/nxdbmgr/upgrade.cpp
src/snmp/libnxsnmp/transport.cpp

index 8831d7d..0a3611b 100644 (file)
@@ -1281,9 +1281,15 @@ src/server/core/nxcore.vcproj -text
 src/server/core/upload_job.cpp -text
 src/server/drivers/baystack.ndd -text
 src/server/drivers/baystack/baystack.vcproj -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/include/Makefile.am -text
 src/server/libnxsrv/apinfo.cpp -text
 src/server/libnxsrv/libnxsrv.vcproj -text
+src/server/libnxsrv/ndd.cpp -text
+src/server/libnxsrv/snmp.cpp -text
 src/server/netxmsd/netxmsd.vcproj -text
 src/server/smsdrv/generic/generic.vcproj -text
 src/server/smsdrv/generic/pdumode.cpp -text
index 9d7ed25..35da3e6 100644 (file)
@@ -1,4 +1,13 @@
 ***************
+* 222 ==> 223 *
+***************
+
+- Column "node_type" dropped from table "nodes"
+- Column "primary_name" added to table "nodes"
+- Table "oid_to_type" dropped
+
+
+***************
 * 217 ==> 218 *
 ***************
 
index 51f265f..88bd9b8 100644 (file)
@@ -35,7 +35,6 @@ EXTRA_DIST = \
        nxlog.h \
        nxlpapi.h \
        nxmbapi.h \
-       nxnt.h \
        nxqueue.h \
        nxsl_classes.h \
        nxsl.h \
index 832ccf0..a79ff67 100644 (file)
@@ -23,6 +23,6 @@
 #ifndef _netxmsdb_h
 #define _netxmsdb_h
 
-#define DB_FORMAT_VERSION   222
+#define DB_FORMAT_VERSION   223
 
 #endif
index 0ba810d..d23a434 100644 (file)
 #define MAX_SECRET_LENGTH        64
 #define MAX_DB_STRING            256
 #define MAX_PARAM_NAME           256
+#define MAX_DNS_NAME             256
 #define GROUP_FLAG               ((DWORD)0x80000000)
 
 #define NETXMS_MAX_CIPHERS       4
index 59f669a..fa4fd15 100644 (file)
@@ -318,7 +318,11 @@ public:
 
        void set(const TCHAR *key, const TCHAR *value);
        void setPreallocated(TCHAR *key, TCHAR *value);
+       void set(const TCHAR *key, DWORD value);
+
        const TCHAR *get(const TCHAR *key);
+       DWORD getULong(const TCHAR *key, DWORD defaultValue);
+
        void remove(const TCHAR *key);
        void clear();
 
index ffc6aa4..5c24b01 100644 (file)
@@ -601,6 +601,7 @@ protected:
        SNMP_Engine *m_authoritativeEngine;
        SNMP_Engine *m_contextEngine;
        bool m_enableEngineIdAutoupdate;
+       int m_snmpVersion;
 
 public:
    SNMP_Transport();
@@ -625,6 +626,9 @@ public:
 
        void enableEngineIdAutoupdate(bool enabled) { m_enableEngineIdAutoupdate = enabled; }
        bool isEngineIdAutoupdateEnabled() { return m_enableEngineIdAutoupdate; }
+
+       void setSnmpVersion(int version) { m_snmpVersion = version; }
+       int getSnmpVersion() { return m_snmpVersion; }
 };
 
 
index e76cd23..4017dd7 100644 (file)
@@ -438,6 +438,18 @@ EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "drivers", "drivers", "{53997B2A-D94C-428C-816D-938C297A1866}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "baystack", "src\server\drivers\baystack\baystack.vcproj", "{13A91F2E-A17B-4ABA-B5B2-285807BD7832}"
+       ProjectSection(ProjectDependencies) = postProject
+               {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}
+       EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ers8000", "src\server\drivers\ers8000\ers8000.vcproj", "{076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}"
+       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}
+       EndProjectSection
 EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -1181,6 +1193,14 @@ Global
                {13A91F2E-A17B-4ABA-B5B2-285807BD7832}.Release|Win32.ActiveCfg = Release|Win32
                {13A91F2E-A17B-4ABA-B5B2-285807BD7832}.Release|Win32.Build.0 = Release|Win32
                {13A91F2E-A17B-4ABA-B5B2-285807BD7832}.Release|x64.ActiveCfg = Release|Win32
+               {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Win32
+               {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Debug|Win32.ActiveCfg = Debug|Win32
+               {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Debug|Win32.Build.0 = Debug|Win32
+               {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Debug|x64.ActiveCfg = Debug|Win32
+               {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Win32
+               {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Release|Win32.ActiveCfg = Release|Win32
+               {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Release|Win32.Build.0 = Release|Win32
+               {076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}.Release|x64.ActiveCfg = Release|Win32
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
@@ -1267,5 +1287,6 @@ Global
                {2DEF303B-5FEF-4F5E-87C4-FB7895058F59} = {89B3A66E-5853-4B14-A5E3-9E4C6524BE65}
                {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}
        EndGlobalSection
 EndGlobal
index 8ae53e4..527a1a7 100644 (file)
@@ -206,6 +206,7 @@ CREATE TABLE zone_ip_addr_list
 CREATE TABLE nodes
 (
        id integer not null,
+       primary_name varchar(255) null,
        primary_ip varchar(15) not null,
        node_flags integer not null,
        snmp_version integer not null,
@@ -219,7 +220,6 @@ CREATE TABLE nodes
        secret varchar(64) null,
        agent_port integer not null,
        status_poll_type integer not null,
-       node_type integer not null,
        agent_version varchar(63) null,
        platform_name varchar(63) null,
        poller_node_id integer not null,
@@ -829,20 +829,6 @@ CREATE INDEX idx_alarm_notes_alarm_id ON alarm_notes(alarm_id);
 
 
 /*
-** OID to node type translation
-*/
-
-CREATE TABLE oid_to_type
-(
-       pair_id integer not null,
-       snmp_oid varchar(255) not null,
-       node_type integer not null,
-       node_flags integer not null,
-       PRIMARY KEY(pair_id)
-) TABLE_TYPE;
-
-
-/*
 ** SNMP trap configuration
 */
 
index 6545937..8f6d2a3 100644 (file)
@@ -301,73 +301,3 @@ INSERT INTO container_categories (category,name,image_id,description)
    VALUES (2,'Location',0,'Geografic location');
 INSERT INTO container_categories (category,name,image_id,description)
    VALUES (3,'Service',0,'Logical service');
-
-
-/*
-** SNMP OID to node type mappings
-*/
-
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (0,'.1.3.6.1.4.1.2272.*',NODE_TYPE_NORTEL_ACCELAR,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (1,'.1.3.6.1.4.1.3224.1.*',NODE_TYPE_NETSCREEN,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (2,'.1.3.6.1.4.1.45.3.26.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (3,'.1.3.6.1.4.1.45.3.30.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (4,'.1.3.6.1.4.1.45.3.31.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (5,'.1.3.6.1.4.1.45.3.32.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (6,'.1.3.6.1.4.1.45.3.33.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (7,'.1.3.6.1.4.1.45.3.34.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (8,'.1.3.6.1.4.1.45.3.35.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (9,'.1.3.6.1.4.1.45.3.36.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (10,'.1.3.6.1.4.1.45.3.40.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (11,'.1.3.6.1.4.1.45.3.46.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (12,'.1.3.6.1.4.1.45.3.52.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (13,'.1.3.6.1.4.1.45.3.61.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (14,'.1.3.6.1.4.1.45.3.48.*',NODE_TYPE_NORTEL_OPTERA,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (15,'.1.3.6.1.4.1.45.3.29.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (16,'.1.3.6.1.4.1.45.3.41.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (17,'.1.3.6.1.4.1.45.3.45.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (18,'.1.3.6.1.4.1.45.3.43.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (19,'.1.3.6.1.4.1.45.3.57.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (20,'.1.3.6.1.4.1.45.3.49.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (21,'.1.3.6.1.4.1.45.3.54.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (22,'.1.3.6.1.4.1.45.3.63.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (23,'.1.3.6.1.4.1.45.3.64.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (24,'.1.3.6.1.4.1.45.3.53.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (25,'.1.3.6.1.4.1.45.3.59.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (26,'.1.3.6.1.4.1.45.3.39.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (27,'.1.3.6.1.4.1.45.3.65.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (28,'.1.3.6.1.4.1.45.3.66.*',NODE_TYPE_NORTEL_BAYSTACK,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (29,'.1.3.6.1.4.1.45.3.44.*',NODE_TYPE_NORTEL_OPTERA,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (30,'.1.3.6.1.4.1.45.3.47.*',NODE_TYPE_NORTEL_OPTERA,0);
-INSERT INTO oid_to_type (pair_id,snmp_oid,node_type,node_flags)
-   VALUES (31,'.1.3.6.1.4.1.45.3.48.*',NODE_TYPE_NORTEL_OPTERA,0);
index 2a4b361..8d1a661 100644 (file)
@@ -172,6 +172,14 @@ void StringMap::set(const TCHAR *key, const TCHAR *value)
        }
 }
 
+void StringMap::set(const TCHAR *key, DWORD value)
+{
+       TCHAR buffer[32];
+
+       _sntprintf(buffer, 32, _T("%u"), (unsigned int)value);
+       set(key, buffer);
+}
+
 
 //
 // Get value by key
@@ -185,6 +193,14 @@ const TCHAR *StringMap::get(const TCHAR *key)
        return (index != INVALID_INDEX) ? m_values[index] : NULL;
 }
 
+DWORD StringMap::getULong(const TCHAR *key, DWORD defaultValue)
+{
+       const TCHAR *value = get(key);
+       if (value == NULL)
+               return defaultValue;
+       return _tcstoul(value, NULL, 0);
+}
+
 
 //
 // Delete value
index 92980c7..3fdbc11 100644 (file)
@@ -15,7 +15,7 @@ libnxcore_la_SOURCES = acl.cpp agent.cpp agent_policy.cpp actions.cpp \
                        layer2.cpp lln.cpp lldp.cpp locks.cpp logfilter.cpp \
                        loghandle.cpp logs.cpp main.cpp map.cpp modules.cpp \
                        ndp.cpp netinfo.cpp netmap.cpp netobj.cpp netsrv.cpp \
-                       node.cpp nortel.cpp np.cpp nxsl_classes.cpp nxslext.cpp \
+                       node.cpp np.cpp nxsl_classes.cpp nxslext.cpp \
                        objects.cpp objtools.cpp package.cpp poll.cpp \
                        radius.cpp rootobj.cpp script.cpp session.cpp \
                        situation.cpp sms.cpp snmp.cpp snmptrap.cpp \
index 22388d8..9864bb9 100644 (file)
@@ -125,7 +125,6 @@ QWORD g_qwServerId;
 RSA *g_pServerKey = NULL;
 time_t g_tServerStartTime = 0;
 DWORD g_dwLockTimeout = 60000;   // Default timeout for acquiring mutex
-DWORD g_dwSNMPTimeout = 2000;          // Default timeout for SNMP requests
 DWORD g_dwAgentCommandTimeout = 2000;  // Default timeout for requests to agent
 DWORD g_dwThresholdRepeatInterval = 0; // Disabled by default
 int g_nRequiredPolls = 1;
@@ -643,9 +642,6 @@ retry_db_lock:
        // Initialize certificate store and CA
        InitCertificates();
 
-       // Initialize SNMP stuff
-       SnmpInit();
-
        // Create synchronization stuff
        m_condShutdown = ConditionCreate(TRUE);
 
index f9fda24..21c6e3f 100644 (file)
 Node::Node()
      :Template()
 {
+       m_primaryName[0] = 0;
    m_iStatus = STATUS_UNKNOWN;
    m_dwFlags = 0;
    m_dwDynamicFlags = 0;
    m_dwZoneGUID = 0;
-   m_dwNodeType = NODE_TYPE_GENERIC;
    m_wAgentPort = AGENT_LISTEN_PORT;
    m_wAuthMethod = AUTH_NONE;
    m_szSharedSecret[0] = 0;
@@ -89,12 +89,12 @@ Node::Node()
 Node::Node(DWORD dwAddr, DWORD dwFlags, DWORD dwProxyNode, DWORD dwSNMPProxy, DWORD dwZone)
      :Template()
 {
+       IpToStr(dwAddr, m_primaryName);
    m_iStatus = STATUS_UNKNOWN;
    m_dwIpAddr = dwAddr;
    m_dwFlags = dwFlags;
    m_dwDynamicFlags = 0;
    m_dwZoneGUID = dwZone;
-   m_dwNodeType = NODE_TYPE_GENERIC;
    m_wAgentPort = AGENT_LISTEN_PORT;
    m_wAuthMethod = AUTH_NONE;
    m_szSharedSecret[0] = 0;
@@ -189,10 +189,9 @@ BOOL Node::CreateFromDB(DWORD dwId)
       return FALSE;
    }
 
-   _sntprintf(query, 1024, _T("SELECT primary_ip,node_flags,")
+   _sntprintf(query, 1024, _T("SELECT primary_name,primary_ip,node_flags,")
                            _T("snmp_version,auth_method,secret,")
-                           _T("agent_port,status_poll_type,snmp_oid,")
-                           _T("node_type,agent_version,")
+                           _T("agent_port,status_poll_type,snmp_oid,agent_version,")
                            _T("platform_name,poller_node_id,zone_guid,")
                            _T("proxy_node,snmp_proxy,required_polls,uname,")
                                                                        _T("use_ifxtable,snmp_port,community,usm_auth_password,")
@@ -209,15 +208,15 @@ BOOL Node::CreateFromDB(DWORD dwId)
       return FALSE;
    }
 
-   m_dwIpAddr = DBGetFieldIPAddr(hResult, 0, 0);
-   m_dwFlags = DBGetFieldULong(hResult, 0, 1);
-   m_snmpVersion = DBGetFieldLong(hResult, 0, 2);
-   m_wAuthMethod = (WORD)DBGetFieldLong(hResult, 0, 3);
-   DBGetField(hResult, 0, 4, m_szSharedSecret, MAX_SECRET_LENGTH);
-   m_wAgentPort = (WORD)DBGetFieldLong(hResult, 0, 5);
-   m_iStatusPollType = DBGetFieldLong(hResult, 0, 6);
-   DBGetField(hResult, 0, 7, m_szObjectId, MAX_OID_LEN * 4);
-   m_dwNodeType = DBGetFieldULong(hResult, 0, 8);
+   DBGetField(hResult, 0, 0, m_primaryName, MAX_DNS_NAME);
+   m_dwIpAddr = DBGetFieldIPAddr(hResult, 0, 1);
+   m_dwFlags = DBGetFieldULong(hResult, 0, 2);
+   m_snmpVersion = DBGetFieldLong(hResult, 0, 3);
+   m_wAuthMethod = (WORD)DBGetFieldLong(hResult, 0, 4);
+   DBGetField(hResult, 0, 5, m_szSharedSecret, MAX_SECRET_LENGTH);
+   m_wAgentPort = (WORD)DBGetFieldLong(hResult, 0, 6);
+   m_iStatusPollType = DBGetFieldLong(hResult, 0, 7);
+   DBGetField(hResult, 0, 8, m_szObjectId, MAX_OID_LEN * 4);
    DBGetField(hResult, 0, 9, m_szAgentVersion, MAX_AGENT_VERSION_LEN);
    DBGetField(hResult, 0, 10, m_szPlatformName, MAX_PLATFORM_NAME_LEN);
    m_dwPollerNode = DBGetFieldULong(hResult, 0, 11);
@@ -327,19 +326,20 @@ BOOL Node::SaveToDB(DB_HANDLE hdb)
    if (bNewObject)
        {
       _sntprintf(szQuery, 4096,
-                 _T("INSERT INTO nodes (id,primary_ip,snmp_port,")
+                 _T("INSERT INTO nodes (id,primary_ip,primary_name,snmp_port,")
                  _T("node_flags,snmp_version,community,status_poll_type,")
                  _T("agent_port,auth_method,secret,snmp_oid,proxy_node,")
-                 _T("node_type,agent_version,platform_name,uname,")
+                 _T("agent_version,platform_name,uname,")
                  _T("poller_node_id,zone_guid,snmp_proxy,required_polls,")
                           _T("use_ifxtable,usm_auth_password,usm_priv_password,usm_methods,snmp_sys_name) VALUES ")
-                          _T("(%d,'%s',%d,%d,%d,%s,%d,%d,%d,%s,%s,%d,%d,%s,%s,%s,%d,%d,%d,%d,%d,%s,%s,%d,%s)"),
-                 m_dwId, IpToStr(m_dwIpAddr, szIpAddr), (int)m_wSNMPPort, m_dwFlags,
-                 m_snmpVersion, (const TCHAR *)DBPrepareStringA(hdb, m_snmpSecurity->getCommunity()),
+                          _T("(%d,'%s',%s,%d,%d,%d,%s,%d,%d,%d,%s,%s,%d,%s,%s,%s,%d,%d,%d,%d,%d,%s,%s,%d,%s)"),
+                 m_dwId, IpToStr(m_dwIpAddr, szIpAddr), (const TCHAR *)DBPrepareString(hdb, m_primaryName),
+                                         (int)m_wSNMPPort, m_dwFlags, m_snmpVersion, (
+                                         const TCHAR *)DBPrepareStringA(hdb, m_snmpSecurity->getCommunity()),
                                          m_iStatusPollType, (int)m_wAgentPort, m_wAuthMethod, 
                                          (const TCHAR *)DBPrepareString(hdb, m_szSharedSecret),
                                          (const TCHAR *)DBPrepareString(hdb, m_szObjectId),
-                 m_dwProxyNode, m_dwNodeType, (const TCHAR *)DBPrepareString(hdb, m_szAgentVersion),
+                 m_dwProxyNode, (const TCHAR *)DBPrepareString(hdb, m_szAgentVersion),
                  (const TCHAR *)DBPrepareString(hdb, m_szPlatformName),
                                          (const TCHAR *)DBPrepareString(hdb, m_sysDescription),
                           m_dwPollerNode, m_dwZoneGUID, m_dwSNMPProxy, m_iRequiredPollCount, m_nUseIfXTable,
@@ -350,19 +350,18 @@ BOOL Node::SaveToDB(DB_HANDLE hdb)
    else
        {
       _sntprintf(szQuery, 4096,
-                 _T("UPDATE nodes SET primary_ip='%s',snmp_port=%d,")
+                       _T("UPDATE nodes SET primary_ip='%s',primary_name=%s,snmp_port=%d,")
                  _T("node_flags=%d,snmp_version=%d,community=%s,")
                  _T("status_poll_type=%d,agent_port=%d,auth_method=%d,secret=%s,")
-                 _T("snmp_oid=%s,node_type=%d,uname=%s,")
-                 _T("agent_version=%s,platform_name=%s,poller_node_id=%d,")
+                 _T("snmp_oid=%s,uname=%s,agent_version=%s,platform_name=%s,poller_node_id=%d,")
                  _T("zone_guid=%d,proxy_node=%d,snmp_proxy=%d,")
                                          _T("required_polls=%d,use_ifxtable=%d,usm_auth_password=%s,")
                                          _T("usm_priv_password=%s,usm_methods=%d,snmp_sys_name=%s WHERE id=%d"),
-                 IpToStr(m_dwIpAddr, szIpAddr), m_wSNMPPort, 
+                 IpToStr(m_dwIpAddr, szIpAddr), (const TCHAR *)DBPrepareString(hdb, m_primaryName), m_wSNMPPort, 
                  m_dwFlags, m_snmpVersion, (const TCHAR *)DBPrepareStringA(hdb, m_snmpSecurity->getCommunity()),
                  m_iStatusPollType, m_wAgentPort, m_wAuthMethod,
                                          (const TCHAR *)DBPrepareString(hdb, m_szSharedSecret), 
-                 (const TCHAR *)DBPrepareString(hdb, m_szObjectId), m_dwNodeType,
+                 (const TCHAR *)DBPrepareString(hdb, m_szObjectId),
                                          (const TCHAR *)DBPrepareString(hdb, m_sysDescription),
                  (const TCHAR *)DBPrepareString(hdb, m_szAgentVersion),
                                          (const TCHAR *)DBPrepareString(hdb, m_szPlatformName), m_dwPollerNode, m_dwZoneGUID,
@@ -1471,8 +1470,6 @@ void Node::configurationPoll(ClientSession *pSession, DWORD dwRqId,
                        SNMP_SecurityContext *newCtx = SnmpCheckCommSettings(pTransport, &m_snmpVersion, m_snmpSecurity);
                        if (newCtx != NULL)
          {
-            DWORD dwNodeFlags, dwNodeType;
-
             LockData();
                                delete m_snmpSecurity;
                                m_snmpSecurity = newCtx;
@@ -1499,18 +1496,6 @@ void Node::configurationPoll(ClientSession *pSession, DWORD dwRqId,
                                        UnlockData();
                                }
 
-            // Check node type
-                               LockData();
-            dwNodeType = OidToType(m_szObjectId, &dwNodeFlags);
-            if (m_dwNodeType != dwNodeType)
-            {
-               m_dwFlags |= dwNodeFlags;
-               m_dwNodeType = dwNodeType;
-               SendPollerMsg(dwRqId, POLLER_WARNING _T("   Node type has been changed to %d\r\n"), m_dwNodeType);
-               bHasChanges = TRUE;
-            }
-                               UnlockData();
-
             // Check IP forwarding
             if (CheckSNMPIntegerValue(pTransport, _T(".1.3.6.1.2.1.4.1.0"), 1))
             {
@@ -2646,7 +2631,6 @@ void Node::CreateMessage(CSCPMessage *pMsg)
        pMsg->SetVariable(VID_SNMP_USM_METHODS, (WORD)((WORD)m_snmpSecurity->getAuthMethod() | ((WORD)m_snmpSecurity->getPrivMethod() << 8)));
    pMsg->SetVariable(VID_SNMP_OID, m_szObjectId);
    pMsg->SetVariable(VID_SNMP_PORT, m_wSNMPPort);
-   pMsg->SetVariable(VID_NODE_TYPE, m_dwNodeType);
    pMsg->SetVariable(VID_SNMP_VERSION, (WORD)m_snmpVersion);
    pMsg->SetVariable(VID_AGENT_VERSION, m_szAgentVersion);
    pMsg->SetVariable(VID_PLATFORM_NAME, m_szPlatformName);
@@ -3430,7 +3414,7 @@ void Node::setAgentProxy(AgentConnection *pConn)
 // Prepare node object for deletion
 //
 
-void Node::PrepareForDeletion(void)
+void Node::PrepareForDeletion()
 {
    // Prevent node from being queued for polling
    LockData();
@@ -3476,45 +3460,8 @@ BOOL Node::CheckSNMPIntegerValue(SNMP_Transport *pTransport, const TCHAR *pszOID
 
 void Node::CheckInterfaceNames(InterfaceList *pIfList)
 {
-   int i;
-   TCHAR *ptr;
-
-   if ((m_dwNodeType == NODE_TYPE_NORTEL_BAYSTACK) ||
-                (m_dwNodeType == NODE_TYPE_NORTEL_OPTERA))
-   {
-      // Translate interface names
-      for(i = 0; i < pIfList->getSize(); i++)
-      {
-                       INTERFACE_INFO *iface = pIfList->get(i);
-
-         if ((ptr = _tcsstr(iface->szName, _T("- Port"))) != NULL)
-                       {
-                               ptr += 2;
-            memmove(iface->szName, ptr, _tcslen(ptr) + 1);
-                       }
-         else if ((ptr = _tcsstr(iface->szName, _T("- Unit"))) != NULL)
-                       {
-                               ptr += 2;
-            memmove(iface->szName, ptr, _tcslen(ptr) + 1);
-                       }
-         else if ((_tcsstr(iface->szName, _T("BayStack")) != NULL) ||
-                  (_tcsstr(iface->szName, _T("Nortel Ethernet Switch")) != NULL))
-         {
-            ptr = _tcsrchr(iface->szName, _T('-'));
-            if (ptr != NULL)
-            {
-               ptr++;
-               while(*ptr == _T(' '))
-                  ptr++;
-               memmove(iface->szName, ptr, _tcslen(ptr) + 1);
-            }
-         }
-                       StrStrip(iface->szName);
-      }
-   }
-
    // Cut interface names to MAX_OBJECT_NAME and check for unnamed interfaces
-   for(i = 0; i < pIfList->getSize(); i++)
+   for(int i = 0; i < pIfList->getSize(); i++)
    {
       pIfList->get(i)->szName[MAX_OBJECT_NAME - 1] = 0;
       if (pIfList->get(i)->szName[0] == 0)
@@ -3582,6 +3529,7 @@ SNMP_Transport *Node::createSnmpTransport(WORD port)
        {
                LockData();
                pTransport->setSecurityContext(new SNMP_SecurityContext(m_snmpSecurity));
+               pTransport->setSnmpVersion(m_snmpVersion);
                UnlockData();
        }
        return pTransport;
index f3d9fc9..7cb295c 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\nortel.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
                                RelativePath=".\np.cpp"\r
                                >\r
                        </File>\r
index afdfc58..c31b877 100644 (file)
@@ -1,6 +1,6 @@
 /* 
 ** NetXMS - Network Management System
-** Copyright (C) 2003-2010 Victor Kirhenshtein
+** 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
 
 
 //
-// OID translation structure
-//
-
-struct OID_TABLE
-{
-   TCHAR *pszOid;
-   DWORD dwNodeType;
-   DWORD dwNodeFlags;
-};
-
-
-//
-// Static data
-//
-
-static OID_TABLE *m_pOidTable = NULL;
-static DWORD m_dwOidTableSize = 0;
-static DWORD m_dwRequestId = 1;
-
-
-//
-// Generate new request ID
-//
-
-DWORD SnmpNewRequestId()
-{
-   return m_dwRequestId++;
-}
-
-
-//
-// Initialize SNMP subsystem
-//
-
-void SnmpInit()
-{
-   DB_RESULT hResult;
-   DWORD i;
-
-   // Load OID to type translation table
-   hResult = DBSelect(g_hCoreDB, _T("SELECT snmp_oid,node_type,node_flags FROM oid_to_type ORDER BY pair_id"));
-   if (hResult != NULL)
-   {
-      m_dwOidTableSize = DBGetNumRows(hResult);
-      m_pOidTable = (OID_TABLE *)malloc(sizeof(OID_TABLE) * m_dwOidTableSize);
-      for(i = 0; i < m_dwOidTableSize; i++)
-      {
-         m_pOidTable[i].pszOid = DBGetField(hResult, i, 0, NULL, 0);
-         m_pOidTable[i].dwNodeType = DBGetFieldULong(hResult, i, 1);
-         m_pOidTable[i].dwNodeFlags = DBGetFieldULong(hResult, i, 2);
-      }
-      DBFreeResult(hResult);
-   }
-}
-
-
-//
-// Determine node type by OID
-//
-
-DWORD OidToType(TCHAR *pszOid, DWORD *pdwFlags)
-{
-   DWORD i;
-
-   for(i = 0; i < m_dwOidTableSize; i++)
-      if (MatchString(m_pOidTable[i].pszOid, pszOid, TRUE))
-      {
-         if (pdwFlags != NULL)
-            *pdwFlags = m_pOidTable[i].dwNodeFlags;
-         return m_pOidTable[i].dwNodeType;
-      }
-
-   *pdwFlags = 0;
-   return NODE_TYPE_GENERIC;
-}
-
-
-//
-// Get value for SNMP variable
-// If szOidStr is not NULL, string representation of OID is used, otherwise -
-// binary representation from oidBinary and dwOidLen
-//
-
-DWORD SnmpGet(DWORD dwVersion, SNMP_Transport *pTransport,
-              const TCHAR *szOidStr, const DWORD *oidBinary, DWORD dwOidLen, void *pValue,
-              DWORD dwBufferSize, DWORD dwFlags)
-{
-   SNMP_PDU *pRqPDU, *pRespPDU;
-   DWORD dwNameLen, pdwVarName[MAX_OID_LEN], dwResult = SNMP_ERR_SUCCESS;
-
-       if (pTransport == NULL)
-               return SNMP_ERR_COMM;
-
-   // Create PDU and send request
-   pRqPDU = new SNMP_PDU(SNMP_GET_REQUEST, m_dwRequestId++, dwVersion);
-   if (szOidStr != NULL)
-   {
-      dwNameLen = SNMPParseOID(szOidStr, pdwVarName, MAX_OID_LEN);
-      if (dwNameLen == 0)
-      {
-         nxlog_write(MSG_OID_PARSE_ERROR, EVENTLOG_ERROR_TYPE, "s", szOidStr);
-         dwResult = SNMP_ERR_BAD_OID;
-      }
-   }
-   else
-   {
-      memcpy(pdwVarName, oidBinary, dwOidLen * sizeof(DWORD));
-      dwNameLen = dwOidLen;
-   }
-
-   if (dwResult == SNMP_ERR_SUCCESS)   // Still no errors
-   {
-      pRqPDU->bindVariable(new SNMP_Variable(pdwVarName, dwNameLen));
-      dwResult = pTransport->doRequest(pRqPDU, &pRespPDU, g_dwSNMPTimeout, 3);
-
-      // Analyze response
-      if (dwResult == SNMP_ERR_SUCCESS)
-      {
-         if ((pRespPDU->getNumVariables() > 0) &&
-             (pRespPDU->getErrorCode() == SNMP_PDU_ERR_SUCCESS))
-         {
-            SNMP_Variable *pVar = pRespPDU->getVariable(0);
-
-            if ((pVar->GetType() != ASN_NO_SUCH_OBJECT) &&
-                (pVar->GetType() != ASN_NO_SUCH_INSTANCE))
-            {
-               if (dwFlags & SG_RAW_RESULT)
-               {
-                                               pVar->getRawValue((BYTE *)pValue, dwBufferSize);
-               }
-               else if (dwFlags & SG_HSTRING_RESULT)
-               {
-                                               int rawLen = (dwBufferSize - 1) / 2;
-                                               BYTE *raw = (BYTE *)malloc(rawLen);
-                                               rawLen = pVar->getRawValue(raw, rawLen);
-                                               BinToStr(raw, rawLen, (TCHAR *)pValue);
-                                               free(raw);
-               }
-               else if (dwFlags & SG_STRING_RESULT)
-               {
-                  pVar->GetValueAsString((TCHAR *)pValue, dwBufferSize);
-               }
-               else
-               {
-                  switch(pVar->GetType())
-                  {
-                     case ASN_INTEGER:
-                     case ASN_UINTEGER32:
-                     case ASN_COUNTER32:
-                     case ASN_GAUGE32:
-                     case ASN_TIMETICKS:
-                        *((LONG *)pValue) = pVar->GetValueAsInt();
-                        break;
-                     case ASN_IP_ADDR:
-                        *((DWORD *)pValue) = ntohl(pVar->GetValueAsUInt());
-                        break;
-                     case ASN_OCTET_STRING:
-                        pVar->GetValueAsString((TCHAR *)pValue, dwBufferSize);
-                        break;
-                     case ASN_OBJECT_ID:
-                        pVar->GetValueAsString((TCHAR *)pValue, dwBufferSize);
-                        break;
-                     default:
-                        nxlog_write(MSG_SNMP_UNKNOWN_TYPE, EVENTLOG_ERROR_TYPE, "x", pVar->GetType());
-                        dwResult = SNMP_ERR_BAD_TYPE;
-                        break;
-                  }
-               }
-            }
-            else
-            {
-               dwResult = SNMP_ERR_NO_OBJECT;
-            }
-         }
-         else
-         {
-            if (pRespPDU->getErrorCode() == SNMP_PDU_ERR_NO_SUCH_NAME)
-               dwResult = SNMP_ERR_NO_OBJECT;
-            else
-               dwResult = SNMP_ERR_AGENT;
-         }
-         delete pRespPDU;
-      }
-      else
-      {
-         if (dwFlags & SG_VERBOSE)
-            nxlog_write(MSG_SNMP_GET_ERROR, EVENTLOG_ERROR_TYPE, "d", dwResult);
-      }
-   }
-
-   delete pRqPDU;
-   return dwResult;
-}
-
-
-//
-// Enumerate multiple values by walking through MIB, starting at given root
-//
-
-DWORD SnmpEnumerate(DWORD dwVersion, SNMP_Transport *pTransport, const TCHAR *szRootOid,
-                    DWORD (* pHandler)(DWORD, SNMP_Variable *, SNMP_Transport *, void *),
-                    void *pUserArg, BOOL bVerbose)
-{
-   DWORD pdwRootName[MAX_OID_LEN], dwRootLen, pdwName[MAX_OID_LEN], dwNameLen, dwResult;
-   SNMP_PDU *pRqPDU, *pRespPDU;
-   BOOL bRunning = TRUE;
-
-       if (pTransport == NULL)
-               return SNMP_ERR_COMM;
-
-   // Get root
-   dwRootLen = SNMPParseOID(szRootOid, pdwRootName, MAX_OID_LEN);
-   if (dwRootLen == 0)
-   {
-      nxlog_write(MSG_OID_PARSE_ERROR, EVENTLOG_ERROR_TYPE, "s", szRootOid);
-      dwResult = SNMP_ERR_BAD_OID;
-   }
-   else
-   {
-      memcpy(pdwName, pdwRootName, dwRootLen * sizeof(DWORD));
-      dwNameLen = dwRootLen;
-
-      // Walk the MIB
-      while(bRunning)
-      {
-         pRqPDU = new SNMP_PDU(SNMP_GET_NEXT_REQUEST, m_dwRequestId++, dwVersion);
-         pRqPDU->bindVariable(new SNMP_Variable(pdwName, dwNameLen));
-         dwResult = pTransport->doRequest(pRqPDU, &pRespPDU, g_dwSNMPTimeout, 3);
-
-         // Analyze response
-         if (dwResult == SNMP_ERR_SUCCESS)
-         {
-            if ((pRespPDU->getNumVariables() > 0) &&
-                (pRespPDU->getErrorCode() == SNMP_PDU_ERR_SUCCESS))
-            {
-               SNMP_Variable *pVar = pRespPDU->getVariable(0);
-
-               if ((pVar->GetType() != ASN_NO_SUCH_OBJECT) &&
-                   (pVar->GetType() != ASN_NO_SUCH_INSTANCE))
-               {
-                  // Should we stop walking?
-                  if ((pVar->GetName()->Length() < dwRootLen) ||
-                      (memcmp(pdwRootName, pVar->GetName()->GetValue(), dwRootLen * sizeof(DWORD))) ||
-                      ((pVar->GetName()->Length() == dwNameLen) &&
-                       (!memcmp(pVar->GetName()->GetValue(), pdwName, pVar->GetName()->Length() * sizeof(DWORD)))))
-                  {
-                     bRunning = FALSE;
-                     delete pRespPDU;
-                     delete pRqPDU;
-                     break;
-                  }
-                  memcpy(pdwName, pVar->GetName()->GetValue(), 
-                         pVar->GetName()->Length() * sizeof(DWORD));
-                  dwNameLen = pVar->GetName()->Length();
-
-                  // Call user's callback function for processing
-                  dwResult = pHandler(dwVersion, pVar, pTransport, pUserArg);
-                  if (dwResult != SNMP_ERR_SUCCESS)
-                  {
-                     bRunning = FALSE;
-                  }
-               }
-               else
-               {
-                  dwResult = SNMP_ERR_NO_OBJECT;
-                  bRunning = FALSE;
-               }
-            }
-            else
-            {
-               if (pRespPDU->getErrorCode() == SNMP_PDU_ERR_NO_SUCH_NAME)
-                  dwResult = SNMP_ERR_NO_OBJECT;
-               else
-                  dwResult = SNMP_ERR_AGENT;
-               bRunning = FALSE;
-            }
-            delete pRespPDU;
-         }
-         else
-         {
-            if (bVerbose)
-               nxlog_write(MSG_SNMP_GET_ERROR, EVENTLOG_ERROR_TYPE, "d", dwResult);
-            bRunning = FALSE;
-         }
-         delete pRqPDU;
-      }
-   }
-   return dwResult;
-}
-
-
-//
 // Handler for enumerating indexes
 //
 
@@ -501,50 +209,10 @@ InterfaceList *SnmpGetInterfaceList(DWORD dwVersion, SNMP_Transport *pTransport,
       if (SnmpEnumerate(dwVersion, pTransport, _T(".1.3.6.1.2.1.4.20.1.1"),
                         HandlerIpAddr, pIfList, FALSE) == SNMP_ERR_SUCCESS)
       {
-         // Handle special cases
-                       if (node->getNodeType() == NODE_TYPE_NORTEL_ACCELAR)
-                       {
-                               // Calculate slot/port pair from ifIndex
-                               for(i = 0; i < pIfList->getSize(); i++)
-                               {
-                                       DWORD slot = pIfList->get(i)->dwIndex / 64;
-                                       if ((slot > 0) && (slot <= 10))
-                                       {
-                                               pIfList->get(i)->dwSlotNumber = slot;
-                                               pIfList->get(i)->dwPortNumber = pIfList->get(i)->dwIndex % 64 + 1;
-                                       }
-                               }
-
-            GetAccelarVLANIfList(dwVersion, pTransport, pIfList);
-                       }
-
                        // Nortel BayStack hack - move to driver
                        if (!_tcsncmp(node->getObjectId(), _T(".1.3.6.1.4.1.45.3"), 17))
                        {
-                               DWORD slotSize;
-                               if (!_tcsncmp(node->getObjectId(), _T(".1.3.6.1.4.1.45.3.74"), 20))     // 56xx
-                               {
-                                       slotSize = 128;
-                               }
-                               else if (!_tcsncmp(node->getObjectId(), _T(".1.3.6.1.4.1.45.3.40"), 20))        // BPS2000
-                               {
-                                       slotSize = 32;
-                               }
-                               else
-                               {
-                                       slotSize = 64;
-                               }
 
-                               // Calculate slot/port pair from ifIndex
-                               for(i = 0; i < pIfList->getSize(); i++)
-                               {
-                                       DWORD slot = pIfList->get(i)->dwIndex / slotSize + 1;
-                                       if ((slot > 0) && (slot <= 8))
-                                       {
-                                               pIfList->get(i)->dwSlotNumber = slot;
-                                               pIfList->get(i)->dwPortNumber = pIfList->get(i)->dwIndex % slotSize;
-                                       }
-                               }
 
                                // Modern switches (55xx, 56xx) supports rapidCity MIBs
             GetAccelarVLANIfList(dwVersion, pTransport, pIfList);
index 168cfac..0236b26 100644 (file)
@@ -31,10 +31,9 @@ static TCHAR s_driverName[] = _T("BAYSTACK");
 static TCHAR s_driverVersion[] = NETXMS_VERSION_STRING;
 
 
-//
-// Driver's class
-//
-
+/**
+ * Driver's class
+ */
 class BayStackDriver : public NetworkDeviceDriver
 {
 public:
@@ -42,50 +41,133 @@ public:
        virtual const TCHAR *getVersion();
 
        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);
 };
 
-
-//
-// Get name
-//
-
+/**
+ * Get driver name
+ */
 const TCHAR *BayStackDriver::getName()
 {
        return s_driverName;
 }
 
-
-//
-// Get version
-//
-
+/**
+ * Get driver version
+ */
 const TCHAR *BayStackDriver::getVersion()
 {
        return s_driverVersion;
 }
 
-
-//
-// Check if given OID is supported
-//
-
+/**
+ * Check if given device is supported by driver
+ *
+ * @param oid Device OID
+ */
 bool BayStackDriver::isDeviceSupported(const TCHAR *oid)
 {
        return _tcsncmp(oid, _T(".1.3.6.1.4.1.45.3"), 17) == 0;
 }
 
+/**
+ * Do additional checks on the device required by driver.
+ * Driver can set device's custom attributes from within
+ * this function.
+ *
+ * @param snmp SNMP transport
+ * @param attributes Node's custom attributes
+ */
+void BayStackDriver::analyzeDevice(SNMP_Transport *snmp, const TCHAR *oid, StringMap *attributes)
+{
+       DWORD slotSize;
+       
+       if (!_tcsncmp(oid, _T(".1.3.6.1.4.1.45.3.74"), 20))     // 56xx
+       {
+               slotSize = 128;
+       }
+       else if (!_tcsncmp(oid, _T(".1.3.6.1.4.1.45.3.40"), 20))        // BPS2000
+       {
+               slotSize = 32;
+       }
+       else
+       {
+               slotSize = 64;
+       }
+
+       attributes->set(_T(".baystack.rapidCity.vlan"), slotSize);
+}
 
-//
-// Driver entry point
-//
+/**
+ * Get list of interfaces for given node
+ *
+ * @param snmp SNMP transport
+ * @param attributes Node's custom attributes
+ */
+InterfaceList *BayStackDriver::getInterfaces(SNMP_Transport *snmp, StringMap *attributes)
+{
+       // Get interface list from standard MIB
+       InterfaceList *ifList = NetworkDeviceDriver::getInterfaces(snmp, attributes);
+       if (ifList == NULL)
+               return NULL;
+
+   // Translate interface names 
+       // TODO: does it really needed?
+   for(int i = 0; i < ifList->getSize(); i++)
+   {
+               INTERFACE_INFO *iface = ifList->get(i);
+
+               const TCHAR *ptr;
+      if ((ptr = _tcsstr(iface->szName, _T("- Port"))) != NULL)
+               {
+                       ptr += 2;
+         memmove(iface->szName, ptr, _tcslen(ptr) + 1);
+               }
+      else if ((ptr = _tcsstr(iface->szName, _T("- Unit"))) != NULL)
+               {
+                       ptr += 2;
+         memmove(iface->szName, ptr, _tcslen(ptr) + 1);
+               }
+      else if ((_tcsstr(iface->szName, _T("BayStack")) != NULL) ||
+               (_tcsstr(iface->szName, _T("Nortel Ethernet Switch")) != NULL))
+      {
+         ptr = _tcsrchr(iface->szName, _T('-'));
+         if (ptr != NULL)
+         {
+            ptr++;
+            while(*ptr == _T(' '))
+               ptr++;
+            memmove(iface->szName, ptr, _tcslen(ptr) + 1);
+         }
+      }
+               StrStrip(iface->szName);
+   }
+       
+       // Calculate slot/port pair from ifIndex
+       DWORD slotSize = attributes->getULong(_T(".baystack.rapidCity.vlan"), 64);
+       for(int i = 0; i < ifList->getSize(); i++)
+       {
+               DWORD slot = ifList->get(i)->dwIndex / slotSize + 1;
+               if ((slot > 0) && (slot <= 8))
+               {
+                       ifList->get(i)->dwSlotNumber = slot;
+                       ifList->get(i)->dwPortNumber = ifList->get(i)->dwIndex % slotSize;
+               }
+       }
+
+       return ifList;
+}
 
+/**
+ * Driver entry point
+ */
 DECLARE_NDD_ENTRY_POINT(s_driverName, BayStackDriver);
 
 
-//
-// DLL entry point
-//
-
+/**
+ * DLL entry point
+ */
 #ifdef _WIN32
 
 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
index 6f28f35..6fefac8 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\include\nms_objects.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
                                RelativePath="..\..\include\nxsrvapi.h"\r
                                >\r
                        </File>\r
diff --git a/src/server/drivers/ers8000/ers8000.cpp b/src/server/drivers/ers8000/ers8000.cpp
new file mode 100644 (file)
index 0000000..72c11d6
--- /dev/null
@@ -0,0 +1,107 @@
+/* \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 Lesser General Public License as published by\r
+** the Free Software Foundation; either version 3 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 Lesser 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: ers8000.cpp\r
+**/\r
+\r
+#include "ers8000.h"\r
+\r
+\r
+//\r
+// Static data\r
+//\r
+\r
+static TCHAR s_driverName[] = _T("ERS8000");\r
+static TCHAR s_driverVersion[] = NETXMS_VERSION_STRING;\r
+\r
+\r
+/**\r
+ * Get driver name\r
+ */\r
+const TCHAR *PassportDriver::getName()\r
+{\r
+       return s_driverName;\r
+}\r
+\r
+/**\r
+ * Get driver version\r
+ */\r
+const TCHAR *PassportDriver::getVersion()\r
+{\r
+       return s_driverVersion;\r
+}\r
+\r
+/**\r
+ * Check if given device is supported by driver\r
+ *\r
+ * @param oid Device OID\r
+ */\r
+bool PassportDriver::isDeviceSupported(const TCHAR *oid)\r
+{\r
+       return _tcsncmp(oid, _T(".1.3.6.1.4.1.2272"), 17) == 0;\r
+}\r
+\r
+/**\r
+ * Get list of interfaces for given node\r
+ *\r
+ * @param snmp SNMP transport\r
+ * @param attributes Node's custom attributes\r
+ */\r
+InterfaceList *PassportDriver::getInterfaces(SNMP_Transport *snmp, StringMap *attributes)\r
+{\r
+       // Get interface list from standard MIB\r
+       InterfaceList *ifList = NetworkDeviceDriver::getInterfaces(snmp, attributes);\r
+       if (ifList == NULL)\r
+               return NULL;\r
+       \r
+       // Calculate slot/port pair from ifIndex\r
+       for(int i = 0; i < ifList->getSize(); i++)\r
+       {\r
+               DWORD slot = ifList->get(i)->dwIndex / 64;\r
+               if ((slot > 0) && (slot <= 10))\r
+               {\r
+                       ifList->get(i)->dwSlotNumber = slot;\r
+                       ifList->get(i)->dwPortNumber = ifList->get(i)->dwIndex % 64 + 1;\r
+               }\r
+       }\r
+\r
+       GetVLANInterfaces(snmp, ifList);\r
+\r
+       return ifList;\r
+}\r
+\r
+/**\r
+ * Driver entry point\r
+ */\r
+DECLARE_NDD_ENTRY_POINT(s_driverName, PassportDriver);\r
+\r
+\r
+/**\r
+ * DLL entry point\r
+ */\r
+#ifdef _WIN32\r
+\r
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)\r
+{\r
+       if (dwReason == DLL_PROCESS_ATTACH)\r
+               DisableThreadLibraryCalls(hInstance);\r
+       return TRUE;\r
+}\r
+\r
+#endif\r
similarity index 54%
rename from include/nxnt.h
rename to src/server/drivers/ers8000/ers8000.h
index 15aa447..e1c7935 100644 (file)
@@ -1,32 +1,48 @@
-/* 
-** NetXMS - Network Management System
-** Copyright (C) 2003, 2004 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.
-**
-** $module: nxnt.h
-**
-**/
-
-#ifndef _nxnt_h
-#define _nxnt_h
-
-#define NODE_TYPE_GENERIC           0
-#define NODE_TYPE_NORTEL_ACCELAR    1
-#define NODE_TYPE_NETSCREEN         2
-#define NODE_TYPE_NORTEL_BAYSTACK   3
-#define NODE_TYPE_NORTEL_OPTERA     4
-
-#endif
+/* \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: ers8000.h\r
+**\r
+**/\r
+\r
+#ifndef _ers8000_h_\r
+#define _ers8000_h_\r
+\r
+#include <nddrv.h>\r
+\r
+\r
+/**\r
+ * Driver's class\r
+ */\r
+class PassportDriver : public NetworkDeviceDriver\r
+{\r
+public:\r
+       virtual const TCHAR *getName();\r
+       virtual const TCHAR *getVersion();\r
+\r
+       virtual bool isDeviceSupported(const TCHAR *oid);\r
+       virtual InterfaceList *getInterfaces(SNMP_Transport *snmp, StringMap *attributes);\r
+};\r
+\r
+/**\r
+ * Functions\r
+ */\r
+void GetVLANInterfaces(SNMP_Transport *pTransport, InterfaceList *pIfList);\r
+\r
+#endif\r
@@ -2,9 +2,9 @@
 <VisualStudioProject\r
        ProjectType="Visual C++"\r
        Version="8.00"\r
-       Name="baystack"\r
-       ProjectGUID="{13A91F2E-A17B-4ABA-B5B2-285807BD7832}"\r
-       RootNamespace="baystack"\r
+       Name="ers8000"\r
+       ProjectGUID="{076E6815-4B6B-4F1E-A36C-CD3DD26EA5AC}"\r
+       RootNamespace="ers8000"\r
        Keyword="Win32Proj"\r
        >\r
        <Platforms>\r
@@ -41,7 +41,7 @@
                                Name="VCCLCompilerTool"\r
                                Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\include;..\..\..\..\include"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BAYSTACK_EXPORTS"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;ERS8000_EXPORTS"\r
                                MinimalRebuild="true"\r
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="3"\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
                                AdditionalIncludeDirectories="..\..\include;..\..\..\..\include"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BAYSTACK_EXPORTS"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;ERS8000_EXPORTS"\r
                                RuntimeLibrary="2"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
                        >\r
                        <File\r
-                               RelativePath=".\baystack.cpp"\r
+                               RelativePath=".\ers8000.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\vlan.cpp"\r
                                >\r
                        </File>\r
                </Filter>\r
                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
                        >\r
                        <File\r
-                               RelativePath="..\..\include\nddrv.h"\r
+                               RelativePath=".\ers8000.h"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\include\nms_objects.h"\r
+                               RelativePath="..\..\include\nddrv.h"\r
                                >\r
                        </File>\r
                        <File\r
similarity index 83%
rename from src/server/core/nortel.cpp
rename to src/server/drivers/ers8000/vlan.cpp
index 5870aba..d3ca0cf 100644 (file)
-/* 
-** NetXMS - Network Management System
-** Copyright (C) 2003, 2004, 2005, 2006, 2007 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: nortel.cpp
-**
-**/
-
-#include "nxcore.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 Passport
-//
-
-static DWORD HandlerVlanList(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)
-   {
-               INTERFACE_INFO iface;
-
-               memset(&iface, 0, sizeof(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 Nortel Passport 8000/Accelar switch
-//
-
-void GetAccelarVLANIfList(DWORD dwVersion, SNMP_Transport *pTransport, InterfaceList *pIfList)
-{
-   VLAN_LIST vlanList;
-
-   // Get VLAN list
-   memset(&vlanList, 0, sizeof(VLAN_LIST));
-   SnmpEnumerate(dwVersion, pTransport, _T(".1.3.6.1.4.1.2272.1.3.2.1.1"), HandlerVlanList, &vlanList, FALSE);
-
-   // Get interfaces
-   pIfList->setData(&vlanList);
-   SnmpEnumerate(dwVersion, pTransport, _T(".1.3.6.1.4.1.2272.1.8.2.1.1"), 
-                 HandlerPassportIfList, pIfList, FALSE);
-   safe_free(vlanList.pList);
-}
+/* \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
+               INTERFACE_INFO iface;\r
+\r
+               memset(&iface, 0, sizeof(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
index 3212062..99d9d78 100644 (file)
@@ -68,8 +68,8 @@ public:
        virtual const TCHAR *getVersion();
 
        virtual bool isDeviceSupported(const TCHAR *oid);
-       virtual void analyzeDevice(Node *node, SNMP_Transport *snmp);
-       virtual InterfaceList *getInterfaces(Node *node, SNMP_Transport *snmp);
+       virtual void analyzeDevice(SNMP_Transport *snmp, const TCHAR *oid, StringMap *attributes);
+       virtual InterfaceList *getInterfaces(SNMP_Transport *snmp, StringMap *attributes);
 };
 
 
index 178caad..5d4e77d 100644 (file)
@@ -621,16 +621,6 @@ public:
 
 
 //
-// Flags for SnmpGet
-//
-
-#define SG_VERBOSE        0x0001
-#define SG_STRING_RESULT  0x0002
-#define SG_RAW_RESULT     0x0004
-#define SG_HSTRING_RESULT 0x0008
-
-
-//
 // Functions
 //
 
@@ -680,17 +670,8 @@ void StopDBWriter();
 
 void DecodeSQLStringAndSetVariable(CSCPMessage *pMsg, DWORD dwVarId, TCHAR *pszStr);
 
-void SnmpInit();
-DWORD SnmpNewRequestId();
-DWORD SnmpGet(DWORD dwVersion, SNMP_Transport *pTransport,
-              const TCHAR *szOidStr, const DWORD *oidBinary, DWORD dwOidLen, void *pValue,
-              DWORD dwBufferSize, DWORD dwFlags);
-DWORD SnmpEnumerate(DWORD dwVersion, SNMP_Transport *pTransport, const TCHAR *szRootOid,
-                                                 DWORD (* pHandler)(DWORD, SNMP_Variable *, SNMP_Transport *, void *),
-                    void *pUserArg, BOOL bVerbose);
 SNMP_SecurityContext *SnmpCheckCommSettings(SNMP_Transport *pTransport, int *version, SNMP_SecurityContext *originalContext);
 void StrToMac(const TCHAR *pszStr, BYTE *pBuffer);
-DWORD OidToType(TCHAR *pszOid, DWORD *pdwFlags);
 
 void InitLocalNetInfo();
 
@@ -703,18 +684,18 @@ int SnmpGetInterfaceStatus(DWORD dwVersion, SNMP_Transport *pTransport, DWORD dw
 
 ROUTING_TABLE *SnmpGetRoutingTable(DWORD dwVersion, SNMP_Transport *pTransport);
 
-void WatchdogInit(void);
+void WatchdogInit();
 DWORD WatchdogAddThread(const TCHAR *szName, time_t tNotifyInterval);
 void WatchdogNotify(DWORD dwId);
 void WatchdogPrintStatus(CONSOLE_CTX pCtx);
 
-void CheckForMgmtNode(void);
+void CheckForMgmtNode();
 Node *PollNewNode(DWORD dwIpAddr, DWORD dwNetMask, DWORD dwCreationFlags,
                   TCHAR *pszName, DWORD dwProxyNode, DWORD dwSNMPProxy, Cluster *pCluster);
 
 void NXCORE_EXPORTABLE EnumerateClientSessions(void (*pHandler)(ClientSession *, void *), void *pArg);
 void NXCORE_EXPORTABLE NotifyClientSessions(DWORD dwCode, DWORD dwData);
-int GetSessionCount(void);
+int GetSessionCount();
 
 void GetSysInfoStr(TCHAR *pszBuffer, int nMaxSize);
 DWORD GetLocalIpAddr();
@@ -810,7 +791,6 @@ extern DWORD g_dwPingSize;
 extern DWORD g_dwAuditFlags;
 extern time_t g_tServerStartTime;
 extern DWORD g_dwLockTimeout;
-extern DWORD g_dwSNMPTimeout;
 extern DWORD g_dwAgentCommandTimeout;
 extern DWORD g_dwThresholdRepeatInterval;
 extern int g_nRequiredPolls;
index 615cd2a..8311bb3 100644 (file)
@@ -24,7 +24,6 @@
 #define _nms_objects_h_
 
 #include <nms_agent.h>
-#include <nxnt.h>
 #include <netxms_maps.h>
 #include <geolocation.h>
 #include "nxcore_jobs.h"
@@ -636,6 +635,7 @@ public:
 class NXCORE_EXPORTABLE Node : public Template
 {
 protected:
+       TCHAR m_primaryName[MAX_DNS_NAME];
    DWORD m_dwFlags;
    DWORD m_dwDynamicFlags;       // Flags used at runtime by server
        int m_iPendingStatus;
@@ -644,7 +644,6 @@ protected:
    DWORD m_dwZoneGUID;
    WORD m_wAgentPort;
    WORD m_wAuthMethod;
-   DWORD m_dwNodeType;
    TCHAR m_szSharedSecret[MAX_SECRET_LENGTH];
    int m_iStatusPollType;
    int m_snmpVersion;
@@ -731,7 +730,6 @@ public:
    DWORD getFlags() { return m_dwFlags; }
    DWORD getRuntimeFlags() { return m_dwDynamicFlags; }
    DWORD getZoneGUID() { return m_dwZoneGUID; }
-       DWORD getNodeType() { return m_dwNodeType; }
    void setLocalMgmtFlag() { m_dwFlags |= NF_IS_LOCAL_MGMT; }
    void clearLocalMgmtFlag() { m_dwFlags &= ~NF_IS_LOCAL_MGMT; }
 
index a900049..62182ea 100644 (file)
 
 
 //
+// Flags for SnmpGet
+//
+
+#define SG_VERBOSE        0x0001
+#define SG_STRING_RESULT  0x0002
+#define SG_RAW_RESULT     0x0004
+#define SG_HSTRING_RESULT 0x0008
+
+
+//
 // Win32 service and syslog constants
 //
 
@@ -481,12 +491,21 @@ void LIBNXSRV_EXPORTABLE SetAgentDEP(int iPolicy);
 
 const TCHAR LIBNXSRV_EXPORTABLE *ISCErrorCodeToText(DWORD code);
 
+DWORD LIBNXSRV_EXPORTABLE SnmpNewRequestId();
+DWORD LIBNXSRV_EXPORTABLE SnmpGet(DWORD dwVersion, SNMP_Transport *pTransport,
+                                  const TCHAR *szOidStr, const DWORD *oidBinary, DWORD dwOidLen, void *pValue,
+                                  DWORD dwBufferSize, DWORD dwFlags);
+DWORD LIBNXSRV_EXPORTABLE SnmpEnumerate(DWORD dwVersion, SNMP_Transport *pTransport, const TCHAR *szRootOid,
+                                                                     DWORD (* pHandler)(DWORD, SNMP_Variable *, SNMP_Transport *, void *),
+                                        void *pUserArg, BOOL bVerbose);
+
 
 //
 // Variables
 //
 
 extern DWORD LIBNXSRV_EXPORTABLE g_dwFlags;
+extern DWORD LIBNXSRV_EXPORTABLE g_dwSNMPTimeout;
 extern int LIBNXSRV_EXPORTABLE g_nDebugLevel;
 
 #endif   /* _nxsrvapi_h_ */
index 11cf012..5c12662 100644 (file)
@@ -1,8 +1,8 @@
 INCLUDES=-I@top_srcdir@/include -I@top_srcdir@/src/server/include
 
 lib_LTLIBRARIES = libnxsrv.la
-libnxsrv_la_SOURCES = messages.c agent.cpp apinfo.cpp isc.cpp license.cpp \
-                      main.cpp snmpproxy.cpp
+libnxsrv_la_SOURCES = messages.c agent.cpp apinfo.cpp iflist.cpp isc.cpp \
+                      license.cpp main.cpp ndd.cpp snmpproxy.cpp
 libnxsrv_la_LDFLAGS = -version-info $(NETXMS_LIBRARY_VERSION)
 libnxsrv_la_LIBADD = ../../libnetxms/libnetxms.la ../../snmp/libnxsnmp/libnxsnmp.la
 
index eeaf007..c45167c 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath=".\ndd.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\snmp.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\snmpproxy.cpp"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\include\nddrv.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\..\..\include\netxms-version.h"\r
                                >\r
                        </File>\r
index cb3cd6b..c07b826 100644 (file)
@@ -29,6 +29,7 @@
 //
 
 DWORD LIBNXSRV_EXPORTABLE g_dwFlags = AF_USE_SYSLOG;
+DWORD LIBNXSRV_EXPORTABLE g_dwSNMPTimeout = 2000;
 int LIBNXSRV_EXPORTABLE g_nDebugLevel = 0;
 
 
diff --git a/src/server/libnxsrv/ndd.cpp b/src/server/libnxsrv/ndd.cpp
new file mode 100644 (file)
index 0000000..15822c1
--- /dev/null
@@ -0,0 +1,91 @@
+/* \r
+** NetXMS - Network Management System\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 Lesser General Public License as published by\r
+** the Free Software Foundation; either version 3 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 Lesser 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: ndd.cpp\r
+**/\r
+\r
+#include "libnxsrv.h"\r
+#include <nddrv.h>\r
+\r
+\r
+//\r
+// Constructor\r
+//\r
+\r
+NetworkDeviceDriver::NetworkDeviceDriver()\r
+{\r
+}\r
+\r
+\r
+//\r
+// Destructor\r
+//\r
+\r
+NetworkDeviceDriver::~NetworkDeviceDriver()\r
+{\r
+}\r
+\r
+/**\r
+ * Get driver name\r
+ */\r
+const TCHAR *NetworkDeviceDriver::getName()\r
+{\r
+       return _T("GENERIC");\r
+}\r
+\r
+/**\r
+ * Get driver version\r
+ */\r
+const TCHAR *NetworkDeviceDriver::getVersion()\r
+{\r
+       return NETXMS_VERSION_STRING;\r
+}\r
+\r
+/**\r
+ * Check if given device is supported by driver\r
+ *\r
+ * @param oid Device OID\r
+ */\r
+bool NetworkDeviceDriver::isDeviceSupported(const TCHAR *oid)\r
+{\r
+       return true;\r
+}\r
+\r
+\r
+/**\r
+ * Do additional checks on the device required by driver.\r
+ * Driver can set device's custom attributes from within\r
+ * this function.\r
+ *\r
+ * @param snmp SNMP transport\r
+ * @param attributes Node's custom attributes\r
+ */\r
+void NetworkDeviceDriver::analyzeDevice(SNMP_Transport *snmp, const TCHAR *oid, StringMap *attributes)\r
+{\r
+}\r
+\r
+/**\r
+ * Get list of interfaces for given node\r
+ *\r
+ * @param snmp SNMP transport\r
+ * @param attributes Node's custom attributes\r
+ */\r
+InterfaceList *NetworkDeviceDriver::getInterfaces(SNMP_Transport *snmp, StringMap *attributes)\r
+{\r
+       return NULL;\r
+}\r
diff --git a/src/server/libnxsrv/snmp.cpp b/src/server/libnxsrv/snmp.cpp
new file mode 100644 (file)
index 0000000..e77ee4d
--- /dev/null
@@ -0,0 +1,254 @@
+/* \r
+** NetXMS - Network Management System\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: snmp.cpp\r
+**\r
+**/\r
+\r
+#include "libnxsrv.h"\r
+\r
+\r
+//\r
+// Static data\r
+//\r
+\r
+static DWORD m_dwRequestId = 1;\r
+\r
+\r
+//\r
+// Generate new request ID\r
+//\r
+\r
+DWORD LIBNXSRV_EXPORTABLE SnmpNewRequestId()\r
+{\r
+   return m_dwRequestId++;\r
+}\r
+\r
+\r
+//\r
+// Get value for SNMP variable\r
+// If szOidStr is not NULL, string representation of OID is used, otherwise -\r
+// binary representation from oidBinary and dwOidLen\r
+//\r
+\r
+DWORD LIBNXSRV_EXPORTABLE SnmpGet(DWORD dwVersion, SNMP_Transport *pTransport,\r
+                                  const TCHAR *szOidStr, const DWORD *oidBinary, DWORD dwOidLen, void *pValue,\r
+                                  DWORD dwBufferSize, DWORD dwFlags)\r
+{\r
+   SNMP_PDU *pRqPDU, *pRespPDU;\r
+   DWORD dwNameLen, pdwVarName[MAX_OID_LEN], dwResult = SNMP_ERR_SUCCESS;\r
+\r
+       if (pTransport == NULL)\r
+               return SNMP_ERR_COMM;\r
+\r
+   // Create PDU and send request\r
+   pRqPDU = new SNMP_PDU(SNMP_GET_REQUEST, m_dwRequestId++, dwVersion);\r
+   if (szOidStr != NULL)\r
+   {\r
+      dwNameLen = SNMPParseOID(szOidStr, pdwVarName, MAX_OID_LEN);\r
+      if (dwNameLen == 0)\r
+      {\r
+         nxlog_write(MSG_OID_PARSE_ERROR, EVENTLOG_ERROR_TYPE, "s", szOidStr);\r
+         dwResult = SNMP_ERR_BAD_OID;\r
+      }\r
+   }\r
+   else\r
+   {\r
+      memcpy(pdwVarName, oidBinary, dwOidLen * sizeof(DWORD));\r
+      dwNameLen = dwOidLen;\r
+   }\r
+\r
+   if (dwResult == SNMP_ERR_SUCCESS)   // Still no errors\r
+   {\r
+      pRqPDU->bindVariable(new SNMP_Variable(pdwVarName, dwNameLen));\r
+      dwResult = pTransport->doRequest(pRqPDU, &pRespPDU, g_dwSNMPTimeout, 3);\r
+\r
+      // Analyze response\r
+      if (dwResult == SNMP_ERR_SUCCESS)\r
+      {\r
+         if ((pRespPDU->getNumVariables() > 0) &&\r
+             (pRespPDU->getErrorCode() == SNMP_PDU_ERR_SUCCESS))\r
+         {\r
+            SNMP_Variable *pVar = pRespPDU->getVariable(0);\r
+\r
+            if ((pVar->GetType() != ASN_NO_SUCH_OBJECT) &&\r
+                (pVar->GetType() != ASN_NO_SUCH_INSTANCE))\r
+            {\r
+               if (dwFlags & SG_RAW_RESULT)\r
+               {\r
+                                               pVar->getRawValue((BYTE *)pValue, dwBufferSize);\r
+               }\r
+               else if (dwFlags & SG_HSTRING_RESULT)\r
+               {\r
+                                               int rawLen = (dwBufferSize - 1) / 2;\r
+                                               BYTE *raw = (BYTE *)malloc(rawLen);\r
+                                               rawLen = pVar->getRawValue(raw, rawLen);\r
+                                               BinToStr(raw, rawLen, (TCHAR *)pValue);\r
+                                               free(raw);\r
+               }\r
+               else if (dwFlags & SG_STRING_RESULT)\r
+               {\r
+                  pVar->GetValueAsString((TCHAR *)pValue, dwBufferSize);\r
+               }\r
+               else\r
+               {\r
+                  switch(pVar->GetType())\r
+                  {\r
+                     case ASN_INTEGER:\r
+                     case ASN_UINTEGER32:\r
+                     case ASN_COUNTER32:\r
+                     case ASN_GAUGE32:\r
+                     case ASN_TIMETICKS:\r
+                        *((LONG *)pValue) = pVar->GetValueAsInt();\r
+                        break;\r
+                     case ASN_IP_ADDR:\r
+                        *((DWORD *)pValue) = ntohl(pVar->GetValueAsUInt());\r
+                        break;\r
+                     case ASN_OCTET_STRING:\r
+                        pVar->GetValueAsString((TCHAR *)pValue, dwBufferSize);\r
+                        break;\r
+                     case ASN_OBJECT_ID:\r
+                        pVar->GetValueAsString((TCHAR *)pValue, dwBufferSize);\r
+                        break;\r
+                     default:\r
+                        nxlog_write(MSG_SNMP_UNKNOWN_TYPE, EVENTLOG_ERROR_TYPE, "x", pVar->GetType());\r
+                        dwResult = SNMP_ERR_BAD_TYPE;\r
+                        break;\r
+                  }\r
+               }\r
+            }\r
+            else\r
+            {\r
+               dwResult = SNMP_ERR_NO_OBJECT;\r
+            }\r
+         }\r
+         else\r
+         {\r
+            if (pRespPDU->getErrorCode() == SNMP_PDU_ERR_NO_SUCH_NAME)\r
+               dwResult = SNMP_ERR_NO_OBJECT;\r
+            else\r
+               dwResult = SNMP_ERR_AGENT;\r
+         }\r
+         delete pRespPDU;\r
+      }\r
+      else\r
+      {\r
+         if (dwFlags & SG_VERBOSE)\r
+            nxlog_write(MSG_SNMP_GET_ERROR, EVENTLOG_ERROR_TYPE, "d", dwResult);\r
+      }\r
+   }\r
+\r
+   delete pRqPDU;\r
+   return dwResult;\r
+}\r
+\r
+\r
+//\r
+// Enumerate multiple values by walking through MIB, starting at given root\r
+//\r
+\r
+DWORD LIBNXSRV_EXPORTABLE SnmpEnumerate(DWORD dwVersion, SNMP_Transport *pTransport, const TCHAR *szRootOid,\r
+                                        DWORD (* pHandler)(DWORD, SNMP_Variable *, SNMP_Transport *, void *),\r
+                                        void *pUserArg, BOOL bVerbose)\r
+{\r
+   DWORD pdwRootName[MAX_OID_LEN], dwRootLen, pdwName[MAX_OID_LEN], dwNameLen, dwResult;\r
+   SNMP_PDU *pRqPDU, *pRespPDU;\r
+   BOOL bRunning = TRUE;\r
+\r
+       if (pTransport == NULL)\r
+               return SNMP_ERR_COMM;\r
+\r
+   // Get root\r
+   dwRootLen = SNMPParseOID(szRootOid, pdwRootName, MAX_OID_LEN);\r
+   if (dwRootLen == 0)\r
+   {\r
+      nxlog_write(MSG_OID_PARSE_ERROR, EVENTLOG_ERROR_TYPE, "s", szRootOid);\r
+      dwResult = SNMP_ERR_BAD_OID;\r
+   }\r
+   else\r
+   {\r
+      memcpy(pdwName, pdwRootName, dwRootLen * sizeof(DWORD));\r
+      dwNameLen = dwRootLen;\r
+\r
+      // Walk the MIB\r
+      while(bRunning)\r
+      {\r
+         pRqPDU = new SNMP_PDU(SNMP_GET_NEXT_REQUEST, m_dwRequestId++, dwVersion);\r
+         pRqPDU->bindVariable(new SNMP_Variable(pdwName, dwNameLen));\r
+         dwResult = pTransport->doRequest(pRqPDU, &pRespPDU, g_dwSNMPTimeout, 3);\r
+\r
+         // Analyze response\r
+         if (dwResult == SNMP_ERR_SUCCESS)\r
+         {\r
+            if ((pRespPDU->getNumVariables() > 0) &&\r
+                (pRespPDU->getErrorCode() == SNMP_PDU_ERR_SUCCESS))\r
+            {\r
+               SNMP_Variable *pVar = pRespPDU->getVariable(0);\r
+\r
+               if ((pVar->GetType() != ASN_NO_SUCH_OBJECT) &&\r
+                   (pVar->GetType() != ASN_NO_SUCH_INSTANCE))\r
+               {\r
+                  // Should we stop walking?\r
+                  if ((pVar->GetName()->Length() < dwRootLen) ||\r
+                      (memcmp(pdwRootName, pVar->GetName()->GetValue(), dwRootLen * sizeof(DWORD))) ||\r
+                      ((pVar->GetName()->Length() == dwNameLen) &&\r
+                       (!memcmp(pVar->GetName()->GetValue(), pdwName, pVar->GetName()->Length() * sizeof(DWORD)))))\r
+                  {\r
+                     bRunning = FALSE;\r
+                     delete pRespPDU;\r
+                     delete pRqPDU;\r
+                     break;\r
+                  }\r
+                  memcpy(pdwName, pVar->GetName()->GetValue(), \r
+                         pVar->GetName()->Length() * sizeof(DWORD));\r
+                  dwNameLen = pVar->GetName()->Length();\r
+\r
+                  // Call user's callback function for processing\r
+                  dwResult = pHandler(dwVersion, pVar, pTransport, pUserArg);\r
+                  if (dwResult != SNMP_ERR_SUCCESS)\r
+                  {\r
+                     bRunning = FALSE;\r
+                  }\r
+               }\r
+               else\r
+               {\r
+                  dwResult = SNMP_ERR_NO_OBJECT;\r
+                  bRunning = FALSE;\r
+               }\r
+            }\r
+            else\r
+            {\r
+               if (pRespPDU->getErrorCode() == SNMP_PDU_ERR_NO_SUCH_NAME)\r
+                  dwResult = SNMP_ERR_NO_OBJECT;\r
+               else\r
+                  dwResult = SNMP_ERR_AGENT;\r
+               bRunning = FALSE;\r
+            }\r
+            delete pRespPDU;\r
+         }\r
+         else\r
+         {\r
+            if (bVerbose)\r
+               nxlog_write(MSG_SNMP_GET_ERROR, EVENTLOG_ERROR_TYPE, "d", dwResult);\r
+            bRunning = FALSE;\r
+         }\r
+         delete pRqPDU;\r
+      }\r
+   }\r
+   return dwResult;\r
+}\r
index f06bcd4..96d6b20 100644 (file)
@@ -249,6 +249,26 @@ static BOOL SetColumnNullable(const TCHAR *table, const TCHAR *column, const TCH
 
 
 //
+// Upgrade from V222 to V223
+//
+
+static BOOL H_UpgradeFromV222(int currVersion, int newVersion)
+{
+       static TCHAR batch[] = 
+               _T("DROP TABLE oid_to_type\n")
+               _T("ALTER TABLE nodes DROP COLUMN node_type\n")
+               _T("ALTER TABLE nodes ADD primary_name varchar(255)\n")
+               _T("UPDATE nodes SET primary_name=primary_ip\n")
+               _T("<END>");
+
+       CHK_EXEC(SQLBatch(batch));
+
+       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='223' WHERE var_name='SchemaVersion'")));
+   return TRUE;
+}
+
+
+//
 // Upgrade from V221 to V222
 //
 
@@ -5096,6 +5116,7 @@ static struct
        { 219, 220, H_UpgradeFromV219 },
        { 220, 221, H_UpgradeFromV220 },
        { 221, 222, H_UpgradeFromV221 },
+       { 222, 223, H_UpgradeFromV222 },
    { 0, NULL }
 };
 
index 21ec6d2..ae45189 100644 (file)
@@ -54,6 +54,7 @@ SNMP_Transport::SNMP_Transport()
        m_contextEngine = NULL;
        m_securityContext = NULL;
        m_enableEngineIdAutoupdate = false;
+       m_snmpVersion = SNMP_VERSION_2C;
 }