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
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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-02 01:20:05 +00:00
|
|
|
typedef NETIO_STATUS (NETIOAPI_API_ * FPGETIFTABLE2EX)(MIB_IF_TABLE_LEVEL Level, PMIB_IF_TABLE2* Table);
|
|
|
|
typedef VOID (NETIOAPI_API_ * FPFREEMIBTABLE)(PVOID Memory);
|
2010-02-13 03:07:34 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
class CMeasureNet : public CMeasure
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum NET {
|
|
|
|
NET_IN,
|
|
|
|
NET_OUT,
|
|
|
|
NET_TOTAL
|
|
|
|
};
|
|
|
|
|
2011-02-15 16:26:54 +00:00
|
|
|
CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name);
|
2009-02-10 18:37:48 +00:00
|
|
|
virtual ~CMeasureNet();
|
|
|
|
|
|
|
|
virtual bool Update();
|
|
|
|
|
|
|
|
static void UpdateIFTable();
|
|
|
|
|
|
|
|
static void UpdateStats();
|
|
|
|
static void ResetStats();
|
2011-08-03 19:44:40 +00:00
|
|
|
static void ReadStats(const WCHAR* iniFile, std::wstring& statsDate);
|
|
|
|
static void WriteStats(const WCHAR* iniFile, const WCHAR* statsDate);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-02-13 03:07:34 +00:00
|
|
|
static void InitializeNewApi();
|
|
|
|
static void FinalizeNewApi();
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
protected:
|
|
|
|
void ReadConfig(CConfigParser& parser, const WCHAR* section, CMeasureNet::NET net);
|
2010-02-13 03:07:34 +00:00
|
|
|
ULONG64 GetNetOctets(NET net);
|
|
|
|
ULONG64 GetNetStatsValue(NET net);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-08-03 19:44:40 +00:00
|
|
|
static void AppendStatsValue(std::wstring& data, const WCHAR* key, const WCHAR* value);
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
double m_CurrentTraffic;
|
|
|
|
double m_TrafficValue;
|
|
|
|
UINT m_Interface;
|
|
|
|
bool m_Cumulative;
|
|
|
|
std::wstring m_TrafficAction;
|
|
|
|
|
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-02 01:20:05 +00:00
|
|
|
static FPGETIFTABLE2EX c_GetIfTable2Ex;
|
|
|
|
static FPFREEMIBTABLE c_FreeMibTable;
|
|
|
|
static bool c_UseNewApi;
|
2009-02-10 18:37:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|