network device driver API changed; minor fixes
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 29 Dec 2011 16:10:14 +0000 (16:10 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 29 Dec 2011 16:10:14 +0000 (16:10 +0000)
17 files changed:
.gitattributes
ChangeLog
doc/internal/NetworkDeviceDrivers.docx [new file with mode: 0644]
src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/widgets/AlarmList.java
src/server/core/ndd.cpp
src/server/core/node.cpp
src/server/drivers/baystack/baystack.cpp
src/server/drivers/baystack/baystack.h
src/server/drivers/cat2900xl/cat2900xl.cpp
src/server/drivers/cat2900xl/cat2900xl.h
src/server/drivers/ers8000/ers8000.cpp
src/server/drivers/ers8000/ers8000.h
src/server/drivers/netscreen/netscreen.cpp
src/server/drivers/netscreen/netscreen.h
src/server/include/nddrv.h
src/server/include/nms_core.h
src/server/libnxsrv/ndd.cpp

index c7a9fc2..9dab0f3 100644 (file)
@@ -79,6 +79,7 @@ contrib/startup/debian/nxhttpd.in -text
 doc/RadenSolutions.xml -text
 doc/comparison_netxms_nnm.doc -text
 doc/integration/HPOM_Integration.docx -text
+doc/internal/NetworkDeviceDrivers.docx -text
 doc/internal/build.w64 -text
 doc/internal/db_driver_api.txt -text
 doc/internal/dci_perftab.txt -text
index aa7d8de..9e24446 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@
        - Implemented alarm viewer element type in dashboards
        - Syslog monitor
        - Event monitor
+- New MIBs added: CISCO-STACK-MIB, FDDI-SMT73-MIB
 
 
 *
diff --git a/doc/internal/NetworkDeviceDrivers.docx b/doc/internal/NetworkDeviceDrivers.docx
new file mode 100644 (file)
index 0000000..19f58fe
Binary files /dev/null and b/doc/internal/NetworkDeviceDrivers.docx differ
index db65bb4..bb27d17 100644 (file)
@@ -215,7 +215,12 @@ public class AlarmList extends Composite
                        public void run()\r
                        {\r
                                if (!alarmViewer.getControl().isDisposed())\r
-                                       alarmViewer.refresh();\r
+                               {\r
+                                       synchronized(alarmList)\r
+                                       {\r
+                                               alarmViewer.refresh();\r
+                                       }\r
+                               }\r
                        }\r
                });\r
        }\r
index 03608a6..db52515 100644 (file)
@@ -127,10 +127,46 @@ void LoadNetworkDeviceDrivers()
  * @param node Node object to test
  * @returns Pointer to device driver object
  */
-NetworkDeviceDriver *FindDriverForNode(Node *node)
+struct __selected_driver
 {
+       int priority;
+       NetworkDeviceDriver *driver;
+};
+
+static int CompareDrivers(const void *e1, const void *e2)
+{
+       return -(((struct __selected_driver *)e1)->priority - ((struct __selected_driver *)e2)->priority);
+}
+
+NetworkDeviceDriver *FindDriverForNode(Node *node, SNMP_Transport *pTransport)
+{
+       struct __selected_driver selection[MAX_DEVICE_DRIVERS];
+       int selected = 0;
+
        for(int i = 0; i < s_numDrivers; i++)
-               if (s_drivers[i]->isDeviceSupported(node->getObjectId()))
-                       return s_drivers[i];
+       {
+               int pri = s_drivers[i]->isPotentialDevice(node->getObjectId());
+               if (pri > 0)
+               {
+                       if (pri > 255)
+                               pri = 255;
+                       selection[selected].priority = pri;
+                       selection[selected].driver = s_drivers[i];
+                       selected++;
+                       DbgPrintf(6, _T("FindDriverForNode(%s): found potential device driver %s with priority %d"),
+                                 node->Name(), s_drivers[i]->getName(), pri);
+               }
+       }
+
+       if (selected > 0)
+       {
+               qsort(selection, selected, sizeof(struct __selected_driver), CompareDrivers);
+               for(int i = 0 ; i < selected; i++)
+               {
+                       if (selection[i].driver->isDeviceSupported(pTransport, node->getObjectId()))
+                               return selection[i].driver;
+               }
+       }
+
        return s_defaultDriver;
 }
index 665016d..c58b4ca 100644 (file)
@@ -1595,7 +1595,7 @@ void Node::configurationPoll(ClientSession *pSession, DWORD dwRqId,
                                }
 
                                // Select device driver
-                               NetworkDeviceDriver *driver = FindDriverForNode(this);
+                               NetworkDeviceDriver *driver = FindDriverForNode(this, pTransport);
                                DbgPrintf(5, _T("ConfPoll(%s): selected device driver %s"), m_szName, driver->getName());
                                LockData();
                                if (driver != m_driver)
index a9de0e7..b26adcf 100644 (file)
@@ -48,13 +48,24 @@ const TCHAR *BayStackDriver::getVersion()
 }
 
 /**
+ * Check if given device can be potentially supported by driver
+ *
+ * @param oid Device OID
+ */
+int BayStackDriver::isPotentialDevice(const TCHAR *oid)
+{
+       return (_tcsncmp(oid, _T(".1.3.6.1.4.1.45.3"), 17) == 0) ? 127 : 0;
+}
+
+/**
  * Check if given device is supported by driver
  *
+ * @param snmp SNMP transport
  * @param oid Device OID
  */
-bool BayStackDriver::isDeviceSupported(const TCHAR *oid)
+bool BayStackDriver::isDeviceSupported(SNMP_Transport *snmp, const TCHAR *oid)
 {
-       return _tcsncmp(oid, _T(".1.3.6.1.4.1.45.3"), 17) == 0;
+       return true;
 }
 
 /**
index 17a1f65..a6bb04b 100644 (file)
@@ -40,7 +40,8 @@ public:
        virtual const TCHAR *getName();
        virtual const TCHAR *getVersion();
 
-       virtual bool isDeviceSupported(const TCHAR *oid);
+       virtual int isPotentialDevice(const TCHAR *oid);
+       virtual bool isDeviceSupported(SNMP_Transport *snmp, 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);
 };
index 4a131c5..a5e2d9d 100644 (file)
@@ -48,11 +48,11 @@ const TCHAR *Cat2900Driver::getVersion()
 }\r
 \r
 /**\r
- * Check if given device is supported by driver\r
+ * Check if given device can be potentially supported by driver\r
  *\r
  * @param oid Device OID\r
  */\r
-bool Cat2900Driver::isDeviceSupported(const TCHAR *oid)\r
+int Cat2900Driver::isPotentialDevice(const TCHAR *oid)\r
 {\r
        static int supportedDevices[] = { 170, 171, 183, 184, 217, 218, 219, 220, \r
                                          221, 246, 247, 248, 323, 324, 325, 359,\r
@@ -61,13 +61,24 @@ bool Cat2900Driver::isDeviceSupported(const TCHAR *oid)
                                                                                                 560, -1 };\r
 \r
        if (_tcsncmp(oid, _T(".1.3.6.1.4.1.9.1."), 17))\r
-               return false;   // Not a Cisco device\r
+               return 0;       // Not a Cisco device\r
 \r
        int id = _tcstol(&oid[17], NULL, 10);\r
        for(int i = 0; supportedDevices[i] != -1; i++)\r
                if (supportedDevices[i] == id)\r
-                       return true;\r
-       return false;\r
+                       return 200;\r
+       return 0;\r
+}\r
+\r
+/**\r
+ * Check if given device is supported by driver\r
+ *\r
+ * @param snmp SNMP transport\r
+ * @param oid Device OID\r
+ */\r
+bool Cat2900Driver::isDeviceSupported(SNMP_Transport *snmp, const TCHAR *oid)\r
+{\r
+       return true;\r
 }\r
 \r
 /**\r
index e941a61..f8b02c5 100644 (file)
@@ -37,7 +37,8 @@ public:
        virtual const TCHAR *getName();\r
        virtual const TCHAR *getVersion();\r
 \r
-       virtual bool isDeviceSupported(const TCHAR *oid);\r
+       virtual int isPotentialDevice(const TCHAR *oid);\r
+       virtual bool isDeviceSupported(SNMP_Transport *snmp, const TCHAR *oid);\r
        virtual InterfaceList *getInterfaces(SNMP_Transport *snmp, StringMap *attributes, int useAliases, bool useIfXTable);\r
 };\r
 \r
index f361318..22041bd 100644 (file)
@@ -48,13 +48,24 @@ const TCHAR *PassportDriver::getVersion()
 }\r
 \r
 /**\r
+ * Check if given device can be potentially supported by driver\r
+ *\r
+ * @param oid Device OID\r
+ */\r
+int PassportDriver::isPotentialDevice(const TCHAR *oid)\r
+{\r
+       return (_tcsncmp(oid, _T(".1.3.6.1.4.1.2272"), 17) == 0) ? 127 : 0;\r
+}\r
+\r
+/**\r
  * Check if given device is supported by driver\r
  *\r
+ * @param snmp SNMP transport\r
  * @param oid Device OID\r
  */\r
-bool PassportDriver::isDeviceSupported(const TCHAR *oid)\r
+bool PassportDriver::isDeviceSupported(SNMP_Transport *snmp, const TCHAR *oid)\r
 {\r
-       return _tcsncmp(oid, _T(".1.3.6.1.4.1.2272"), 17) == 0;\r
+       return true;\r
 }\r
 \r
 /**\r
index aa4f802..68f00e0 100644 (file)
@@ -37,7 +37,8 @@ public:
        virtual const TCHAR *getName();\r
        virtual const TCHAR *getVersion();\r
 \r
-       virtual bool isDeviceSupported(const TCHAR *oid);\r
+       virtual int isPotentialDevice(const TCHAR *oid);\r
+       virtual bool isDeviceSupported(SNMP_Transport *snmp, const TCHAR *oid);\r
        virtual void analyzeDevice(SNMP_Transport *snmp, const TCHAR *oid, StringMap *attributes);\r
        virtual InterfaceList *getInterfaces(SNMP_Transport *snmp, StringMap *attributes, int useAliases, bool useIfXTable);\r
 };\r
index 82ca8ae..5dd9e19 100644 (file)
@@ -48,13 +48,24 @@ const TCHAR *NetscreenDriver::getVersion()
 }
 
 /**
+ * Check if given device can be potentially supported by driver
+ *
+ * @param oid Device OID
+ */
+int NetscreenDriver::isPotentialDevice(const TCHAR *oid)
+{
+       return (_tcsncmp(oid, _T(".1.3.6.1.4.1.3224.1"), 19) == 0) ? 254 : 0;
+}
+
+/**
  * Check if given device is supported by driver
  *
+ * @param snmp SNMP transport
  * @param oid Device OID
  */
-bool NetscreenDriver::isDeviceSupported(const TCHAR *oid)
+bool NetscreenDriver::isDeviceSupported(SNMP_Transport *snmp, const TCHAR *oid)
 {
-       return _tcsncmp(oid, _T(".1.3.6.1.4.1.3224.1"), 19) == 0;
+       return true;
 }
 
 /**
index a97ddc9..6b87edc 100644 (file)
@@ -36,7 +36,8 @@ public:
        virtual const TCHAR *getName();
        virtual const TCHAR *getVersion();
 
-       virtual bool isDeviceSupported(const TCHAR *oid);
+       virtual int isPotentialDevice(const TCHAR *oid);
+       virtual bool isDeviceSupported(SNMP_Transport *snmp, 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);
 };
index e83466f..2c3147e 100644 (file)
@@ -61,7 +61,8 @@ public:
        virtual const TCHAR *getName();
        virtual const TCHAR *getVersion();
 
-       virtual bool isDeviceSupported(const TCHAR *oid);
+       virtual int isPotentialDevice(const TCHAR *oid);
+       virtual bool isDeviceSupported(SNMP_Transport *snmp, 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);
index 1819fcf..b2c7e45 100644 (file)
@@ -716,7 +716,7 @@ int SnmpGetInterfaceStatus(DWORD dwVersion, SNMP_Transport *pTransport, DWORD dw
 ROUTING_TABLE *SnmpGetRoutingTable(DWORD dwVersion, SNMP_Transport *pTransport);
 
 void LoadNetworkDeviceDrivers();
-NetworkDeviceDriver *FindDriverForNode(Node *node);
+NetworkDeviceDriver *FindDriverForNode(Node *node, SNMP_Transport *pTransport);
 
 void WatchdogInit();
 DWORD WatchdogAddThread(const TCHAR *szName, time_t tNotifyInterval);
index ca114a3..51035bb 100644 (file)
@@ -57,11 +57,22 @@ const TCHAR *NetworkDeviceDriver::getVersion()
 }\r
 \r
 /**\r
+ * Check if given device can be potentially supported by driver\r
+ *\r
+ * @param oid Device OID\r
+ */\r
+int NetworkDeviceDriver::isPotentialDevice(const TCHAR *oid)\r
+{\r
+       return 1;\r
+}\r
+\r
+/**\r
  * Check if given device is supported by driver\r
  *\r
+ * @param snmp SNMP transport\r
  * @param oid Device OID\r
  */\r
-bool NetworkDeviceDriver::isDeviceSupported(const TCHAR *oid)\r
+bool NetworkDeviceDriver::isDeviceSupported(SNMP_Transport *snmp, const TCHAR *oid)\r
 {\r
        return true;\r
 }\r