iphlpapi: Remove unused function getInterfaceStatsByName().
This should have been part of commit 0b5a6c704c
.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4e74fdcebe
commit
8e13903665
|
@ -199,16 +199,6 @@ static DWORD kstat_get_ui32( kstat_t *ksp, const char *name )
|
|||
if (!strcmp( data[i].name, name )) return data[i].value.ui32;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ULONGLONG kstat_get_ui64( kstat_t *ksp, const char *name )
|
||||
{
|
||||
unsigned int i;
|
||||
kstat_named_t *data = ksp->ks_data;
|
||||
|
||||
for (i = 0; i < ksp->ks_ndata; i++)
|
||||
if (!strcmp( data[i].name, name )) return data[i].value.ui64;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SYS_TIHDR_H) && defined(T_OPTMGMT_ACK)
|
||||
|
@ -286,126 +276,6 @@ static void *read_mib_entry( int fd, int level, int name, int *len )
|
|||
}
|
||||
#endif /* HAVE_SYS_TIHDR_H && T_OPTMGMT_ACK */
|
||||
|
||||
DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry)
|
||||
{
|
||||
DWORD ret = ERROR_NOT_SUPPORTED;
|
||||
|
||||
if (!name || !entry) return ERROR_INVALID_PARAMETER;
|
||||
|
||||
#ifdef __linux__
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen("/proc/net/dev", "r")))
|
||||
{
|
||||
DWORD skip;
|
||||
char buf[512], *ptr;
|
||||
int nameLen = strlen(name);
|
||||
|
||||
while ((ptr = fgets(buf, sizeof(buf), fp)))
|
||||
{
|
||||
while (*ptr && isspace(*ptr)) ptr++;
|
||||
if (_strnicmp(ptr, name, nameLen) == 0 && *(ptr + nameLen) == ':')
|
||||
{
|
||||
ptr += nameLen + 1;
|
||||
sscanf( ptr, "%u %u %u %u %u %u %u %u %u %u %u %u",
|
||||
&entry->dwInOctets, &entry->dwInUcastPkts,
|
||||
&entry->dwInErrors, &entry->dwInDiscards,
|
||||
&skip, &skip, &skip,
|
||||
&entry->dwInNUcastPkts, &entry->dwOutOctets,
|
||||
&entry->dwOutUcastPkts, &entry->dwOutErrors,
|
||||
&entry->dwOutDiscards );
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
ret = NO_ERROR;
|
||||
}
|
||||
}
|
||||
#elif defined(HAVE_LIBKSTAT)
|
||||
{
|
||||
kstat_ctl_t *kc;
|
||||
kstat_t *ksp;
|
||||
|
||||
if ((kc = kstat_open()) &&
|
||||
(ksp = kstat_lookup( kc, NULL, -1, (char *)name )) &&
|
||||
kstat_read( kc, ksp, NULL ) != -1 &&
|
||||
ksp->ks_type == KSTAT_TYPE_NAMED)
|
||||
{
|
||||
entry->dwMtu = 1500; /* FIXME */
|
||||
entry->dwSpeed = min( kstat_get_ui64( ksp, "ifspeed" ), ~0u );
|
||||
entry->dwInOctets = kstat_get_ui32( ksp, "rbytes" );
|
||||
entry->dwInNUcastPkts = kstat_get_ui32( ksp, "multircv" );
|
||||
entry->dwInNUcastPkts += kstat_get_ui32( ksp, "brdcstrcv" );
|
||||
entry->dwInUcastPkts = kstat_get_ui32( ksp, "ipackets" ) - entry->dwInNUcastPkts;
|
||||
entry->dwInDiscards = kstat_get_ui32( ksp, "norcvbuf" );
|
||||
entry->dwInErrors = kstat_get_ui32( ksp, "ierrors" );
|
||||
entry->dwInUnknownProtos = kstat_get_ui32( ksp, "unknowns" );
|
||||
entry->dwOutOctets = kstat_get_ui32( ksp, "obytes" );
|
||||
entry->dwOutNUcastPkts = kstat_get_ui32( ksp, "multixmt" );
|
||||
entry->dwOutNUcastPkts += kstat_get_ui32( ksp, "brdcstxmt" );
|
||||
entry->dwOutUcastPkts = kstat_get_ui32( ksp, "opackets" ) - entry->dwOutNUcastPkts;
|
||||
entry->dwOutDiscards = 0; /* FIXME */
|
||||
entry->dwOutErrors = kstat_get_ui32( ksp, "oerrors" );
|
||||
entry->dwOutQLen = kstat_get_ui32( ksp, "noxmtbuf" );
|
||||
ret = NO_ERROR;
|
||||
}
|
||||
if (kc) kstat_close( kc );
|
||||
}
|
||||
#elif defined(HAVE_SYS_SYSCTL_H) && defined(NET_RT_IFLIST)
|
||||
{
|
||||
int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_IFLIST, if_nametoindex(name)};
|
||||
size_t needed;
|
||||
char *buf = NULL, *end;
|
||||
struct if_msghdr *ifm;
|
||||
struct if_data ifdata;
|
||||
|
||||
if(sysctl(mib, ARRAY_SIZE(mib), NULL, &needed, NULL, 0) == -1)
|
||||
{
|
||||
ERR ("failed to get size of iflist\n");
|
||||
goto done;
|
||||
}
|
||||
buf = HeapAlloc (GetProcessHeap (), 0, needed);
|
||||
if (!buf)
|
||||
{
|
||||
ret = ERROR_OUTOFMEMORY;
|
||||
goto done;
|
||||
}
|
||||
if(sysctl(mib, ARRAY_SIZE(mib), buf, &needed, NULL, 0) == -1)
|
||||
{
|
||||
ERR ("failed to get iflist\n");
|
||||
goto done;
|
||||
}
|
||||
for ( end = buf + needed; buf < end; buf += ifm->ifm_msglen)
|
||||
{
|
||||
ifm = (struct if_msghdr *) buf;
|
||||
if(ifm->ifm_type == RTM_IFINFO)
|
||||
{
|
||||
ifdata = ifm->ifm_data;
|
||||
entry->dwMtu = ifdata.ifi_mtu;
|
||||
entry->dwSpeed = ifdata.ifi_baudrate;
|
||||
entry->dwInOctets = ifdata.ifi_ibytes;
|
||||
entry->dwInErrors = ifdata.ifi_ierrors;
|
||||
entry->dwInDiscards = ifdata.ifi_iqdrops;
|
||||
entry->dwInUcastPkts = ifdata.ifi_ipackets;
|
||||
entry->dwInNUcastPkts = ifdata.ifi_imcasts;
|
||||
entry->dwOutOctets = ifdata.ifi_obytes;
|
||||
entry->dwOutUcastPkts = ifdata.ifi_opackets;
|
||||
entry->dwOutErrors = ifdata.ifi_oerrors;
|
||||
ret = NO_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
done:
|
||||
HeapFree (GetProcessHeap (), 0, buf);
|
||||
}
|
||||
#else
|
||||
FIXME( "unimplemented\n" );
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************
|
||||
* GetIcmpStatistics (IPHLPAPI.@)
|
||||
*
|
||||
|
|
|
@ -27,11 +27,6 @@
|
|||
#include "winbase.h"
|
||||
#include "iprtrmib.h"
|
||||
|
||||
/* Fills in entry's interface stats, using name to find them.
|
||||
* Returns ERROR_INVALID_PARAMETER if name or entry is NULL, NO_ERROR otherwise.
|
||||
*/
|
||||
DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry) DECLSPEC_HIDDEN;
|
||||
|
||||
DWORD build_tcp_table(TCP_TABLE_CLASS, void **, BOOL, HANDLE, DWORD, DWORD *) DECLSPEC_HIDDEN;
|
||||
DWORD build_tcp6_table(TCP_TABLE_CLASS, void **, BOOL, HANDLE, DWORD, DWORD *) DECLSPEC_HIDDEN;
|
||||
DWORD build_udp_table(UDP_TABLE_CLASS, void **, BOOL, HANDLE, DWORD, DWORD *) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue