added driver for Cisco ESW switches
[public/netxms.git] / src / server / drivers / cisco-esw / cisco-esw.cpp
CommitLineData
7a5c7db4
VK
1/*
2** NetXMS - Network Management System
3** Driver for Cisco ESW switches
4** Copyright (C) 2003-2012 Victor Kirhenshtein
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU Lesser General Public License as published by
8** the Free Software Foundation; either version 3 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU Lesser General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19**
20** File: cisco-esw.cpp
21**/
22
23#include "cisco-esw.h"
24
25
26//
27// Static data
28//
29
30static TCHAR s_driverName[] = _T("CISCO-ESW");
31static TCHAR s_driverVersion[] = NETXMS_VERSION_STRING;
32
33
34/**
35 * Get driver name
36 */
37const TCHAR *CiscoEswDriver::getName()
38{
39 return s_driverName;
40}
41
42/**
43 * Get driver version
44 */
45const TCHAR *CiscoEswDriver::getVersion()
46{
47 return s_driverVersion;
48}
49
50/**
51 * Check if given device can be potentially supported by driver
52 *
53 * @param oid Device OID
54 */
55int CiscoEswDriver::isPotentialDevice(const TCHAR *oid)
56{
57 if (_tcsncmp(oid, _T(".1.3.6.1.4.1.9.1."), 17) != 0)
58 return 0;
59
60 int model = _tcstol(&oid[17], NULL, 10);
61 if (((model >= 1058) && (model <= 1064)) || (model == 1176) || (model == 1177))
62 return 251;
63 return 0;
64}
65
66/**
67 * Check if given device is supported by driver
68 *
69 * @param snmp SNMP transport
70 * @param oid Device OID
71 */
72bool CiscoEswDriver::isDeviceSupported(SNMP_Transport *snmp, const TCHAR *oid)
73{
74 return true;
75}
76
77/**
78 * Get list of interfaces for given node
79 *
80 * @param snmp SNMP transport
81 * @param attributes Node's custom attributes
82 */
83InterfaceList *CiscoEswDriver::getInterfaces(SNMP_Transport *snmp, StringMap *attributes, int useAliases, bool useIfXTable)
84{
85 // Get interface list from standard MIB
86 InterfaceList *ifList = NetworkDeviceDriver::getInterfaces(snmp, attributes, useAliases, useIfXTable);
87 if (ifList == NULL)
88 return NULL;
89
90 // Find physical ports
91 for(int i = 0; i < ifList->getSize(); i++)
92 {
93 NX_INTERFACE_INFO *iface = ifList->get(i);
94 if ((iface->dwType == IFTYPE_ETHERNET_CSMACD) && (iface->dwIndex <= 48))
95 {
96 iface->isPhysicalPort = true;
97 iface->dwSlotNumber = 1;
98 iface->dwPortNumber = iface->dwIndex;
99 }
100 }
101
102 return ifList;
103}
104
105/**
106 * Driver entry point
107 */
108DECLARE_NDD_ENTRY_POINT(s_driverName, CiscoEswDriver);
109
110/**
111 * DLL entry point
112 */
113#ifdef _WIN32
114
115BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
116{
117 if (dwReason == DLL_PROCESS_ATTACH)
118 DisableThreadLibraryCalls(hInstance);
119 return TRUE;
120}
121
122#endif