"Fossies" - the Fresh Open Source Software Archive

Member "netxms-3.8.166/src/server/drivers/dlink/dlink.cpp" (23 Feb 2021, 3084 Bytes) of package /linux/misc/netxms-3.8.166.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "dlink.cpp" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3.6.300_vs_3.7.95.

    1 /* 
    2 ** NetXMS - Network Management System
    3 ** Driver for D-Link switches
    4 ** Copyright (C) 2003-2013 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: dlink.cpp
   21 **/
   22 
   23 #include "dlink.h"
   24 #include <netxms-version.h>
   25 
   26 /**
   27  * Driver name
   28  */
   29 static TCHAR s_driverName[] = _T("DLINK");
   30 
   31 /**
   32  * Get driver name
   33  */
   34 const TCHAR *DLinkDriver::getName()
   35 {
   36     return s_driverName;
   37 }
   38 
   39 /**
   40  * Get driver version
   41  */
   42 const TCHAR *DLinkDriver::getVersion()
   43 {
   44     return NETXMS_VERSION_STRING;
   45 }
   46 
   47 /**
   48  * Check if given device can be potentially supported by driver
   49  *
   50  * @param oid Device OID
   51  */
   52 int DLinkDriver::isPotentialDevice(const TCHAR *oid)
   53 {
   54     return (_tcsncmp(oid, _T(".1.3.6.1.4.1.171.10."), 20) == 0) ? 127 : 0;
   55 }
   56 
   57 /**
   58  * Check if given device is supported by driver
   59  *
   60  * @param snmp SNMP transport
   61  * @param oid Device OID
   62  */
   63 bool DLinkDriver::isDeviceSupported(SNMP_Transport *snmp, const TCHAR *oid)
   64 {
   65     return true;
   66 }
   67 
   68 /**
   69  * Do additional checks on the device required by driver.
   70  * Driver can set device's custom attributes from within
   71  * this function.
   72  *
   73  * @param snmp SNMP transport
   74  * @param node Node
   75  */
   76 void DLinkDriver::analyzeDevice(SNMP_Transport *snmp, const TCHAR *oid, NObject *node, DriverData **driverData)
   77 {
   78     node->setCustomAttribute(_T(".dlink.slotSize"), 48);
   79 }
   80 
   81 /**
   82  * Get list of interfaces for given node
   83  *
   84  * @param snmp SNMP transport
   85  * @param node Node
   86  */
   87 InterfaceList *DLinkDriver::getInterfaces(SNMP_Transport *snmp, NObject *node, DriverData *driverData, int useAliases, bool useIfXTable)
   88 {
   89     // Get interface list from standard MIB
   90     InterfaceList *ifList = NetworkDeviceDriver::getInterfaces(snmp, node, driverData, useAliases, useIfXTable);
   91     if (ifList == NULL)
   92         return NULL;
   93 
   94     UINT32 slotSize = node->getCustomAttributeAsUInt32(_T(".dlink.slotSize"), 48);
   95 
   96     // Find physical ports
   97     for(int i = 0; i < ifList->size(); i++)
   98     {
   99         InterfaceInfo *iface = ifList->get(i);
  100         if (iface->index < 1024)
  101         {
  102             iface->isPhysicalPort = true;
  103             iface->location.module = (iface->index / slotSize) + 1;
  104             iface->location.port = iface->index % slotSize;
  105         }
  106     }
  107 
  108     return ifList;
  109 }
  110 
  111 /**
  112  * Driver entry point
  113  */
  114 DECLARE_NDD_ENTRY_POINT(DLinkDriver);
  115 
  116 /**
  117  * DLL entry point
  118  */
  119 #ifdef _WIN32
  120 
  121 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  122 {
  123     if (dwReason == DLL_PROCESS_ATTACH)
  124         DisableThreadLibraryCalls(hInstance);
  125     return TRUE;
  126 }
  127 
  128 #endif