Commit d05e538a authored by Gilles Dubois's avatar Gilles Dubois
Browse files

Add MTU for windows agent (WIP)

parent e4615f9d
//====================================================================================
// Open Computer and Software Inventory Next Generation
// Copyright (C) 2010 OCS Inventory NG Team. All rights reserved.
// Web: http://www.ocsinventory-ng.org
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence V2 http://www.gnu.org/ or Licence.txt
//====================================================================================
// InventoryRequest.h: interface for the CInventoryRequest class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_INVENTORYREQUEST_H__84CE64C5_1C6B_4E05_8981_FA8D80E4D3A1__INCLUDED_)
#define AFX_INVENTORYREQUEST_H__84CE64C5_1C6B_4E05_8981_FA8D80E4D3A1__INCLUDED_
#pragma once
#include "OCSInventory Front Classes.h"
#include "Markup.h"
#include "RequestAbstract.h"
#include "OCSInventoryState.h"
#include "Sysinfo.h"
#include "XMLInteract.h"
class OCSINVENTORYFRONT_API CInventoryRequest : public CRequestAbstract
{
public: //Methods
//Standards constructor and destructor
// Optionnally, enable notify mode to send only important informations changes, such as IP informations
CInventoryRequest( BOOL bNotify = FALSE);
virtual ~CInventoryRequest();
// Enable agent to specify a tag
void setTag(CString);
// Do some action when request successfully executed
void setSuccess();
public: //Attributes
// Inventory storing object interaction
CXMLInteract *m_pTheDB;
// General device properties
CDeviceProperties m_Device;
// BIOS informations
CBios m_BIOS;
// List of CPU infos
CCpuList m_CpuList;
// List of Input devices infos
CInputDeviceList m_InputList;
// List of Logical Drives (Volum name, File system, Total size, Free space...)
CLogicalDriveList m_DriveList;
// List of Memory slots
CMemorySlotList m_MemoryList;
// List of Modems
CModemList m_ModemList;
// List of Monitors
CMonitorList m_MonitorList;
// List of Network adapters
CNetworkAdapterList m_NetworkList;
// List of Printers
CPrinterList m_PrinterList;
// List of Device registry values infos
CRegistryValueList m_RegistryList;
// List of Software
CSoftwareList m_SoftwareList;
// List of Sound Devices
CSoundDeviceList m_SoundList;
// List of Storage devices (Floppy disk, IDE Disk, SCSI Disk, CD-Rom...)
CStoragePeripheralList m_StorageList;
// List of System Controlers (Floppy, IDE, SCSI, USB, IEEE1394, PCMCIA, SATA)
CSystemControllerList m_SystemControllerList;
// List of System Slots (PCI, AGP...)
CSystemSlotList m_SlotList;
// List of ports
CSystemPortList m_PortList;
// List of Video adapters
CVideoAdapterList m_VideoList;
private: // Attributes
// The pointer to the sysinfo object
CSysInfo *m_pSysInfo;
// Inventory state for detecting changes
COCSInventoryState *m_pState;
//====================================================================================
// Open Computer and Software Inventory Next Generation
// Copyright (C) 2010 OCS Inventory NG Team. All rights reserved.
// Web: http://www.ocsinventory-ng.org
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence V2 http://www.gnu.org/ or Licence.txt
//====================================================================================
// InventoryRequest.h: interface for the CInventoryRequest class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_INVENTORYREQUEST_H__84CE64C5_1C6B_4E05_8981_FA8D80E4D3A1__INCLUDED_)
#define AFX_INVENTORYREQUEST_H__84CE64C5_1C6B_4E05_8981_FA8D80E4D3A1__INCLUDED_
#pragma once
#include "OCSInventory Front Classes.h"
#include "Markup.h"
#include "RequestAbstract.h"
#include "OCSInventoryState.h"
#include "Sysinfo.h"
#include "XMLInteract.h"
class OCSINVENTORYFRONT_API CInventoryRequest : public CRequestAbstract
{
public: //Methods
//Standards constructor and destructor
// Optionnally, enable notify mode to send only important informations changes, such as IP informations
CInventoryRequest( BOOL bNotify = FALSE);
virtual ~CInventoryRequest();
// Enable agent to specify a tag
void setTag(CString);
// Do some action when request successfully executed
void setSuccess();
public: //Attributes
// Inventory storing object interaction
CXMLInteract *m_pTheDB;
// General device properties
CDeviceProperties m_Device;
// BIOS informations
CBios m_BIOS;
// List of CPU infos
CCpuList m_CpuList;
// List of Input devices infos
CInputDeviceList m_InputList;
// List of Logical Drives (Volum name, File system, Total size, Free space...)
CLogicalDriveList m_DriveList;
// List of Memory slots
CMemorySlotList m_MemoryList;
// List of Modems
CModemList m_ModemList;
// List of Monitors
CMonitorList m_MonitorList;
// List of Network adapters
CNetworkAdapterList m_NetworkList;
// List of Printers
CPrinterList m_PrinterList;
// List of Device registry values infos
CRegistryValueList m_RegistryList;
// List of Software
CSoftwareList m_SoftwareList;
// List of Sound Devices
CSoundDeviceList m_SoundList;
// List of Storage devices (Floppy disk, IDE Disk, SCSI Disk, CD-Rom...)
CStoragePeripheralList m_StorageList;
// List of System Controlers (Floppy, IDE, SCSI, USB, IEEE1394, PCMCIA, SATA)
CSystemControllerList m_SystemControllerList;
// List of System Slots (PCI, AGP...)
CSystemSlotList m_SlotList;
// List of ports
CSystemPortList m_PortList;
// List of Video adapters
CVideoAdapterList m_VideoList;
private: // Attributes
// The pointer to the sysinfo object
CSysInfo *m_pSysInfo;
// Inventory state for detecting changes
COCSInventoryState *m_pState;
COCSInventoryState *m_pPluginState;
// Device TAG
CString m_csTag;
// Is /NOTIFY enabled, to force notifying mode because service detects inventory changes
// Device TAG
CString m_csTag;
// Is /NOTIFY enabled, to force notifying mode because service detects inventory changes
BOOL m_bNotify;
private: // Methods
// Initialize inventory object
BOOL initInventory();
// Inventory the computer using SysInfo.dll
BOOL runInventory();
// Build the inventory CHECKSUM
// Return TRUE is inventory state changed
BOOL isStateChanged();
// Insert download history into inventory
BOOL loadDownloadHistory();
// Search recursively in directory lpstrDir for files with extension in comma separated list lpstrExtension
// Excluding folders in comma separated list lpstrFolderToSkip
// Returns the number of files in folder and subfolders
LONG SearchFilesInDirectory( LPCTSTR lpstrDir, LPCTSTR lpstrExtension = NULL, LPCTSTR lpstrFolderToSkip = NULL);
// Is file name has extension from a coma separated list in csExtension
BOOL IsExtensionToSearch( LPCTSTR lpstrFilename, LPCTSTR lpstrExtension);
// Is folder name is in a coma separated list in csFolderToSkip
BOOL IsExcludeFolder( LPCTSTR lpstrFolder, LPCTSTR lpstrFolderToSkip);
// Finalize inventory
BOOL final();
// Update the last_state file
BOOL writeLastInventoryState();
};
#endif // !defined(AFX_INVENTORYREQUEST_H__84CE64C5_1C6B_4E05_8981_FA8D80E4D3A1__INCLUDED_)
private: // Methods
// Initialize inventory object
BOOL initInventory();
// Inventory the computer using SysInfo.dll
BOOL runInventory();
// Build the inventory CHECKSUM
// Return TRUE is inventory state changed
BOOL isStateChanged();
// Insert download history into inventory
BOOL loadDownloadHistory();
// Search recursively in directory lpstrDir for files with extension in comma separated list lpstrExtension
// Excluding folders in comma separated list lpstrFolderToSkip
// Returns the number of files in folder and subfolders
LONG SearchFilesInDirectory( LPCTSTR lpstrDir, LPCTSTR lpstrExtension = NULL, LPCTSTR lpstrFolderToSkip = NULL);
// Is file name has extension from a coma separated list in csExtension
BOOL IsExtensionToSearch( LPCTSTR lpstrFilename, LPCTSTR lpstrExtension);
// Is folder name is in a coma separated list in csFolderToSkip
BOOL IsExcludeFolder( LPCTSTR lpstrFolder, LPCTSTR lpstrFolderToSkip);
// Finalize inventory
BOOL final();
// Update the last_state file
BOOL writeLastInventoryState();
};
#endif // !defined(AFX_INVENTORYREQUEST_H__84CE64C5_1C6B_4E05_8981_FA8D80E4D3A1__INCLUDED_)
......@@ -657,6 +657,7 @@ BOOL CXMLInteract::UpdateNetworks( CNetworkAdapterList &myNetworkList)
m_pXml->AddChildElem( _T( "IPGATEWAY"), cObject.GetGateway());
m_pXml->AddChildElem( _T( "IPSUBNET"), cObject.GetNetNumber());
m_pXml->AddChildElem( _T( "IPDHCP"), cObject.GetDhcpServer());
m_pXml->AddChildElem( _T( "MTU"), cObject.GetMtu());
m_pXml->OutOfElem();
if (pos != NULL)
cObject = myNetworkList.GetNext( pos);
......
//====================================================================================
// Open Computer and Software Inventory Next Generation
// Copyright (C) 2010 OCS Inventory NG Team. All rights reserved.
// Web: http://www.ocsinventory-ng.org
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence V2 http://www.gnu.org/ or Licence.txt
//====================================================================================
// NetworkAdapter.cpp: implementation of the CNetworkAdapter class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "NetworkAdapter.h"
#include <ipifcons.h>
//====================================================================================
// Open Computer and Software Inventory Next Generation
// Copyright (C) 2010 OCS Inventory NG Team. All rights reserved.
// Web: http://www.ocsinventory-ng.org
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence V2 http://www.gnu.org/ or Licence.txt
//====================================================================================
// NetworkAdapter.cpp: implementation of the CNetworkAdapter class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "NetworkAdapter.h"
#include <ipifcons.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CNetworkAdapter::CNetworkAdapter()
{
Clear();
}
CNetworkAdapter::~CNetworkAdapter()
{
Clear();
}
LPCTSTR CNetworkAdapter::GetNetNumber()
{
return m_csNetNumber;
}
LPCTSTR CNetworkAdapter::GetType()
{
return m_csType;
}
LPCTSTR CNetworkAdapter::GetDescription()
{
return m_csDescription;
}
LPCTSTR CNetworkAdapter::GetSpeed()
{
return m_csSpeed;
}
ULONG CNetworkAdapter::GetByteSpeed()
{
return m_ulSpeed;
}
LPCTSTR CNetworkAdapter::GetMACAddress()
{
return m_csHWAddr;
}
LPCTSTR CNetworkAdapter::GetIPAddress()
{
return m_csIPAddr;
}
LPCTSTR CNetworkAdapter::GetTypeMIB()
{
return m_csTypeMIB;
}
LPCTSTR CNetworkAdapter::GetOperationalStatus()
{
return m_csOperStatus;
}
LPCTSTR CNetworkAdapter::GetIPNetMask()
{
return m_csIPNetMask;
}
LPCTSTR CNetworkAdapter::GetGateway()
{
return m_csGateway;
}
LPCTSTR CNetworkAdapter::GetDhcpServer()
{
return m_csDhcpServer;
}
LONG CNetworkAdapter::GetIfIndex()
{
return m_lIndex;
}
void CNetworkAdapter::SetNetNumber( LPCTSTR nbr )
{
m_csNetNumber = nbr;
StrForSQL( m_csNetNumber);
}
void CNetworkAdapter::SetDescription( LPCTSTR lpstrDescription)
{
m_csDescription = lpstrDescription;
StrForSQL( m_csDescription);
}
void CNetworkAdapter::SetType( LPCTSTR lpstrType)
{
m_csType = lpstrType;
StrForSQL( m_csType);
}
void CNetworkAdapter::SetTypeMIB( LPCTSTR lpstrMIBType)
{
m_csTypeMIB = lpstrMIBType;
StrForSQL( m_csTypeMIB);
}
void CNetworkAdapter::SetSpeed( LPCTSTR lpstrSpeed)
{
CString csBuffer = lpstrSpeed;
m_csSpeed = lpstrSpeed;
StrForSQL( m_csSpeed);
// Recalculate byte speed
if (csBuffer.Find( _T( " Gb/s")) >= 0)
{
csBuffer.TrimRight( _T( " Gb/s"));
m_ulSpeed = _tcstoul( csBuffer, NULL, 10) * 1000000000;
return;
}
if (csBuffer.Find( _T( " Mb/s")) >= 0)
{
csBuffer.TrimRight( _T( " Mb/s"));
m_ulSpeed = _tcstoul( csBuffer, NULL, 10) * 1000000;
return;
}
if (csBuffer.Find( _T( " Kb/s")) >= 0)
{
csBuffer.TrimRight( _T( " Kb/s"));
m_ulSpeed = _tcstoul( csBuffer, NULL, 10) * 1000;
return;
}
csBuffer.TrimRight( _T( " b/s"));
m_ulSpeed = _tcstoul( csBuffer, NULL, 10);
}
void CNetworkAdapter::SetSpeed( ULONG lSpeed)
{
m_ulSpeed = lSpeed;
if (lSpeed >= 1000000000)
m_csSpeed.Format( _T( "%lu Gb/s"), lSpeed / 1000000000);
else
{
if (lSpeed >= 1000000)
m_csSpeed.Format( _T( "%lu Mb/s"), lSpeed / 1000000);
else
{
if (lSpeed >= 1000)
m_csSpeed.Format( _T( "%lu Kb/s"), lSpeed / 1000);
else
m_csSpeed.Format( _T( "%lu b/s"), lSpeed);
}
}
}
void CNetworkAdapter::SetMACAddress( LPCTSTR lpstrMAC)
{
m_csHWAddr = lpstrMAC;
StrForSQL( m_csHWAddr);
}
void CNetworkAdapter::SetStatus( LPCTSTR lpstrStatus)
{
m_csOperStatus = lpstrStatus;
StrForSQL( m_csOperStatus);
}
void CNetworkAdapter::SetStatus( LONG lOperStatus)
{
switch (lOperStatus)
{
case 1: // Up
m_csOperStatus = _T( "Up");
break;
case 2: // Down
m_csOperStatus = _T( "Down");
break;
case 3: // Testing
m_csOperStatus = _T( "Testing");
break;
default: // Unknown
m_csOperStatus = _T( "");
break;
}
}
void CNetworkAdapter::SetIpHelperStatus( LONG lOperStatus)
{
switch (lOperStatus)
{
case MIB_IF_OPER_STATUS_NON_OPERATIONAL:
case MIB_IF_OPER_STATUS_UNREACHABLE:
case MIB_IF_OPER_STATUS_DISCONNECTED:
m_csOperStatus = _T( "Down");
break;
case MIB_IF_OPER_STATUS_CONNECTING:
m_csOperStatus = _T( "Testing");
break;
case MIB_IF_OPER_STATUS_CONNECTED:
case MIB_IF_OPER_STATUS_OPERATIONAL:
m_csOperStatus = _T( "Up");
break;
default: // Unknown
m_csOperStatus = _T( "");
break;
}
}
void CNetworkAdapter::SetIPAddress( LPCTSTR lpstrIP)
{
m_csIPAddr = lpstrIP;
StrForSQL( m_csIPAddr);
}
void CNetworkAdapter::SetIPNetMask( LPCTSTR lpstrNetMask)
{
m_csIPNetMask = lpstrNetMask;
StrForSQL( m_csIPNetMask);
}
void CNetworkAdapter::SetGateway( LPCTSTR lpstrGateway)
{
m_csGateway = lpstrGateway;
StrForSQL( m_csGateway);
}
void CNetworkAdapter::SetDhcpServer( LPCTSTR lpstrDhcpServer)
{
m_csDhcpServer = lpstrDhcpServer;
StrForSQL( m_csDhcpServer);
}
void CNetworkAdapter::SetIfIndex( LONG lIndex)
{
m_lIndex = lIndex;
}
void CNetworkAdapter::Clear()
{
m_csNetNumber.Empty();
m_lIndex = -1;
m_csDescription.Empty();
m_csType.Empty();
m_csTypeMIB.Empty();
m_csSpeed.Empty();
m_ulSpeed = 0;
m_csHWAddr.Empty();
m_csOperStatus.Empty();
m_csIPAddr.Empty();
m_csIPNetMask.Empty();
m_csGateway.Empty();
m_csDhcpServer.Empty();
}
int CNetworkAdapter::operator==(CNetworkAdapter cObject) const
{
return ((m_csNetNumber == cObject.GetNetNumber()) &&
(m_lIndex == cObject.GetIfIndex()) &&
(m_csDescription == cObject.GetDescription()) &&
(m_csType == cObject.GetType()) &&
(m_csTypeMIB == cObject.GetTypeMIB()) &&
(m_csSpeed == cObject.GetSpeed()) &&
(m_ulSpeed == cObject.GetByteSpeed()) &&
(m_csHWAddr == cObject.GetMACAddress()) &&
(m_csOperStatus == cObject.GetOperationalStatus()) &&
(m_csIPAddr == cObject.GetIPAddress()) &&
(m_csIPNetMask == cObject.GetIPNetMask()) &&
(m_csGateway == cObject.GetGateway()) &&
(m_csDhcpServer == cObject.GetDhcpServer()));
}
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CNetworkAdapter::CNetworkAdapter()
{
Clear();
}
CNetworkAdapter::~CNetworkAdapter()
{
Clear();
}
LPCTSTR CNetworkAdapter::GetNetNumber()
{
return m_csNetNumber;
}
LPCTSTR CNetworkAdapter::GetType()
{
return m_csType;
}
LPCTSTR CNetworkAdapter::GetDescription()
{
return m_csDescription;
}
LPCTSTR CNetworkAdapter::GetSpeed()
{
return m_csSpeed;
}
ULONG CNetworkAdapter::GetByteSpeed()
{
return m_ulSpeed;
}
LPCTSTR CNetworkAdapter::GetMACAddress()
{
return m_csHWAddr;
}
LPCTSTR CNetworkAdapter::GetIPAddress()
{
return m_csIPAddr;
}
LPCTSTR CNetworkAdapter::GetTypeMIB()
{
return m_csTypeMIB;
}
LPCTSTR CNetworkAdapter::GetOperationalStatus()
{
return m_csOperStatus;
}
LPCTSTR CNetworkAdapter::GetIPNetMask()
{
return m_csIPNetMask;
}
LPCTSTR CNetworkAdapter::GetGateway()
{
return m_csGateway;
}
LPCTSTR CNetworkAdapter::GetDhcpServer()
{
return m_csDhcpServer;