2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2001 Kimmo Pekkola
|
|
|
|
|
|
|
|
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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-02-10 18:37:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MEASURENET_H__
|
|
|
|
#define __MEASURENET_H__
|
|
|
|
|
2011-03-29 21:19:02 +00:00
|
|
|
#include <winsock2.h>
|
|
|
|
#include <ws2tcpip.h>
|
2011-02-07 08:10:47 +00:00
|
|
|
#include <Iphlpapi.h>
|
2011-03-29 21:19:02 +00:00
|
|
|
#include "Measure.h"
|
2010-02-13 03:07:34 +00:00
|
|
|
|
2011-08-07 09:40:08 +00:00
|
|
|
typedef NETIO_STATUS (NETIOAPI_API_ * FPGETIFTABLE2)(PMIB_IF_TABLE2* Table);
|
2011-08-02 01:20:05 +00:00
|
|
|
typedef VOID (NETIOAPI_API_ * FPFREEMIBTABLE)(PVOID Memory);
|
2010-02-13 03:07:34 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
class MeasureNet : public Measure
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-05-31 14:18:52 +00:00
|
|
|
virtual UINT GetTypeID() { return TypeID<MeasureNet>(); }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
static void UpdateIFTable();
|
|
|
|
|
|
|
|
static void UpdateStats();
|
|
|
|
static void ResetStats();
|
2012-05-20 13:12:13 +00:00
|
|
|
static void ReadStats(const std::wstring& iniFile, std::wstring& statsDate);
|
2011-12-09 19:49:06 +00:00
|
|
|
static void WriteStats(const WCHAR* iniFile, const std::wstring& statsDate);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-11-12 02:10:40 +00:00
|
|
|
static void InitializeStatic();
|
|
|
|
static void FinalizeStatic();
|
2010-02-13 03:07:34 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
protected:
|
2012-10-09 15:33:49 +00:00
|
|
|
enum NET
|
|
|
|
{
|
|
|
|
NET_IN,
|
|
|
|
NET_OUT,
|
|
|
|
NET_TOTAL
|
|
|
|
};
|
2012-05-30 06:46:11 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
MeasureNet(MeterWindow* meterWindow, const WCHAR* name, NET type);
|
|
|
|
virtual ~MeasureNet();
|
2012-10-09 15:33:49 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
virtual void ReadOptions(ConfigParser& parser, const WCHAR* section);
|
2012-10-09 15:33:49 +00:00
|
|
|
virtual void UpdateValue();
|
|
|
|
|
|
|
|
private:
|
2010-02-13 03:07:34 +00:00
|
|
|
ULONG64 GetNetOctets(NET net);
|
|
|
|
ULONG64 GetNetStatsValue(NET net);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-10-09 15:33:49 +00:00
|
|
|
NET m_Net;
|
2009-02-10 18:37:48 +00:00
|
|
|
UINT m_Interface;
|
2012-10-09 15:33:49 +00:00
|
|
|
|
|
|
|
ULONG64 m_Octets;
|
|
|
|
bool m_FirstTime;
|
2009-02-10 18:37:48 +00:00
|
|
|
bool m_Cumulative;
|
|
|
|
|
2010-02-13 03:07:34 +00:00
|
|
|
static std::vector<ULONG64> c_OldStatValues;
|
|
|
|
static std::vector<ULONG64> c_StatValues;
|
|
|
|
static BYTE* c_Table;
|
2009-02-10 18:37:48 +00:00
|
|
|
static UINT c_NumOfTables;
|
2010-02-13 03:07:34 +00:00
|
|
|
|
2011-08-07 09:40:08 +00:00
|
|
|
static FPGETIFTABLE2 c_GetIfTable2;
|
2011-08-02 01:20:05 +00:00
|
|
|
static FPFREEMIBTABLE c_FreeMibTable;
|
2009-02-10 18:37:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|