/*
* UdpStatistics.h
* Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2009/09/04
#pragma once
#include <sol/net/MibTable.h>
#include <sol/Arg.h>
#include <sol/String.h>
namespace SOL {
class UdpStatistics :public MibTable {
/*
typedef struct _MIB_UDPSTATS {
DWORD dwInDatagrams;
DWORD dwNoPorts;
DWORD dwInErrors;
DWORD dwOutDatagrams;
DWORD dwNumAddrs;
}MIB_UDPSTATS, *PMIB_UDPSTATS;
*/
private:
MIB_UDPSTATS table;
private:
ADDRESS_FAMILY family;
public:
UdpStatistics(ADDRESS_FAMILY f=AF_INET)
:family(f)
{
clear();
}
public:
~UdpStatistics()
{
clear();
}
public:
virtual bool getTable()
{
clear();
bool rc = false;
DWORD r = NO_ERROR;
if ((r = GetUdpStatisticsEx(&table, family)) == NO_ERROR){
rc = true;
} else {
clear();
throw r;
}
return rc;
}
public:
void clear()
{
memset(&table, 0, sizeof(table));
}
/*
*/
public:
virtual void display(MIB_UDPSTATS& table)
{
printf("InDatagrams : %lu\n", table.dwInDatagrams);
printf("NoPorts : %lu\n", table.dwNoPorts);
printf("InErrors : %lu\n", table.dwInErrors);
printf("OutDatagrams : %lu\n", table.dwOutDatagrams);
printf("NumAddrs : %lu\n", table.dwNumAddrs);
printf("\n");
}
public:
virtual void display()
{
getTable();
display(table);
}
};
}
|