Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qga: replace GetIfEntry with GetIfEntry2 #5

Open
wants to merge 1 commit into
base: qga
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 33 additions & 13 deletions qga/commands-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,20 +1173,40 @@ static int guest_get_network_stats(const char *name,
GuestNetworkInterfaceStat *stats)
{
DWORD if_index = 0;
MIB_IFROW a_mid_ifrow;
memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
OSVERSIONINFO OSver;
if_index = get_interface_index(name);
a_mid_ifrow.dwIndex = if_index;
if (NO_ERROR == GetIfEntry(&a_mid_ifrow)) {
stats->rx_bytes = a_mid_ifrow.dwInOctets;
stats->rx_packets = a_mid_ifrow.dwInUcastPkts;
stats->rx_errs = a_mid_ifrow.dwInErrors;
stats->rx_dropped = a_mid_ifrow.dwInDiscards;
stats->tx_bytes = a_mid_ifrow.dwOutOctets;
stats->tx_packets = a_mid_ifrow.dwOutUcastPkts;
stats->tx_errs = a_mid_ifrow.dwOutErrors;
stats->tx_dropped = a_mid_ifrow.dwOutDiscards;
return 0;
OSver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OSver);
if (OSver.dwMajorVersion < 6) {
MIB_IFROW a_mid_ifrow;
memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
a_mid_ifrow.dwIndex = if_index;
if (NO_ERROR == GetIfEntry(&a_mid_ifrow)) {
stats->rx_bytes = a_mid_ifrow.dwInOctets;
stats->rx_packets = a_mid_ifrow.dwInUcastPkts;
stats->rx_errs = a_mid_ifrow.dwInErrors;
stats->rx_dropped = a_mid_ifrow.dwInDiscards;
stats->tx_bytes = a_mid_ifrow.dwOutOctets;
stats->tx_packets = a_mid_ifrow.dwOutUcastPkts;
stats->tx_errs = a_mid_ifrow.dwOutErrors;
stats->tx_dropped = a_mid_ifrow.dwOutDiscards;
return 0;
}
} else {
MIB_IFROW2 a_mid_ifrow;
memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
a_mid_ifrow.dwIndex = if_index;
if (NO_ERROR == GetIfEntry2(&a_mid_ifrow)) {
stats->rx_bytes = a_mid_ifrow.dwInOctets;
stats->rx_packets = a_mid_ifrow.dwInUcastPkts;
stats->rx_errs = a_mid_ifrow.dwInErrors;
stats->rx_dropped = a_mid_ifrow.dwInDiscards;
stats->tx_bytes = a_mid_ifrow.dwOutOctets;
stats->tx_packets = a_mid_ifrow.dwOutUcastPkts;
stats->tx_errs = a_mid_ifrow.dwOutErrors;
stats->tx_dropped = a_mid_ifrow.dwOutDiscards;
return 0;
}
}
return -1;
}
Expand Down