mirror of https://github.com/BOINC/boinc.git
- client: Add a function to the client software to be able to detect
the number of bytes sent and received across all non-loopback interfaces. client/ hostinfo_win.cpp svn path=/trunk/boinc/; revision=20704
This commit is contained in:
parent
08cc5d1c83
commit
a5bbf07ccc
|
@ -1352,3 +1352,11 @@ David 20 Feb 2010
|
|||
sample_project.inc
|
||||
inc/
|
||||
util_ops.inc
|
||||
|
||||
Rom 23 Feb 2010
|
||||
- client: Add a function to the client software to be able to detect
|
||||
the number of bytes sent and received across all non-loopback
|
||||
interfaces.
|
||||
|
||||
client/
|
||||
hostinfo_win.cpp
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "str_util.h"
|
||||
#include "str_replace.h"
|
||||
#include "client_msgs.h"
|
||||
#include "error_numbers.h"
|
||||
#include "hostinfo_network.h"
|
||||
#include "hostinfo.h"
|
||||
#include "idlemon.h"
|
||||
|
@ -862,6 +863,57 @@ int get_processor_info(
|
|||
}
|
||||
|
||||
|
||||
// detect the network usage totals for the host.
|
||||
//
|
||||
int get_network_usage_totals(unsigned int& total_received, unsigned int& total_sent) {
|
||||
|
||||
// Declare and initialize variables.
|
||||
int i;
|
||||
int iRetVal = 0;
|
||||
DWORD dwSize = 0;
|
||||
MIB_IFTABLE* pIfTable;
|
||||
MIB_IFROW* pIfRow;
|
||||
|
||||
// Allocate memory for our pointers.
|
||||
pIfTable = (MIB_IFTABLE*)malloc(sizeof(MIB_IFTABLE));
|
||||
if (pIfTable == NULL) {
|
||||
return ERR_MALLOC;
|
||||
}
|
||||
|
||||
// Make an initial call to GetIfTable to get the
|
||||
// necessary size into dwSize
|
||||
dwSize = sizeof(MIB_IFTABLE);
|
||||
if (GetIfTable(pIfTable, &dwSize, FALSE) == ERROR_INSUFFICIENT_BUFFER) {
|
||||
free(pIfTable);
|
||||
pIfTable = (MIB_IFTABLE*)malloc(dwSize);
|
||||
if (pIfTable == NULL) {
|
||||
return ERR_MALLOC;
|
||||
}
|
||||
}
|
||||
|
||||
// Make a second call to GetIfTable to get the actual
|
||||
// data we want.
|
||||
iRetVal = (int)GetIfTable(pIfTable, &dwSize, FALSE);
|
||||
if (iRetVal == NO_ERROR) {
|
||||
for (i = 0; i < (int)pIfTable->dwNumEntries; i++) {
|
||||
pIfRow = (MIB_IFROW *) & pIfTable->table[i];
|
||||
if (IF_TYPE_SOFTWARE_LOOPBACK != pIfRow->dwType) {
|
||||
total_received += pIfRow->dwInOctets;
|
||||
total_sent += pIfRow->dwOutOctets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pIfTable != NULL) {
|
||||
free(pIfTable);
|
||||
pIfTable = NULL;
|
||||
}
|
||||
|
||||
return iRetVal;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Gets host information; called on startup and before each sched RPC
|
||||
//
|
||||
int HOST_INFO::get_host_info() {
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include <shlobj.h>
|
||||
#include <userenv.h>
|
||||
#include <aclapi.h>
|
||||
#include <iphlpapi.h>
|
||||
|
||||
#if !defined(__CYGWIN32__) || defined(USE_WINSOCK)
|
||||
|
||||
|
|
|
@ -409,7 +409,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="zlib1.lib ssleay32.lib libeay32.lib libcurl_imp.lib nvapi.lib MSVCRT.LIB MSVCPRT.LIB wsock32.lib wininet.lib winmm.lib sensapi.lib userenv.lib Iphlpapi.lib kernel32.lib user32.lib advapi32.lib sensapi.lib $(NOINHERIT)"
|
||||
AdditionalDependencies="zlib1.lib ssleay32.lib libeay32.lib libcurl_imp.lib nvapi.lib MSVCRT.LIB MSVCPRT.LIB wsock32.lib wininet.lib winmm.lib sensapi.lib userenv.lib iphlpapi.lib kernel32.lib user32.lib advapi32.lib $(NOINHERIT)"
|
||||
ShowProgress="0"
|
||||
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\boinc.exe"
|
||||
LinkIncremental="1"
|
||||
|
|
Loading…
Reference in New Issue