Eric Durbin : iphlpapi: Implement getIPStats on FreeBSD.
Alexandre Julliard
julliard at winehq.org
Thu Jun 26 06:48:03 CDT 2008
Module: wine
Branch: master
Commit: a00e693f37d4a908d8812521de63ca3ee76059db
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a00e693f37d4a908d8812521de63ca3ee76059db
Author: Eric Durbin <eadurbin at freebsd.org>
Date: Tue Jun 24 22:44:41 2008 -0500
iphlpapi: Implement getIPStats on FreeBSD.
---
dlls/iphlpapi/ipstats.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c
index 772006b..c9b9565 100644
--- a/dlls/iphlpapi/ipstats.c
+++ b/dlls/iphlpapi/ipstats.c
@@ -380,6 +380,57 @@ DWORD getICMPStats(MIB_ICMP *stats)
DWORD getIPStats(PMIB_IPSTATS stats)
{
+#if defined(HAVE_SYS_SYSCTL_H) && defined(IPCTL_STATS)
+ int mib[] = {CTL_NET, PF_INET, IPPROTO_IP, IPCTL_STATS};
+#define MIB_LEN (sizeof(mib) / sizeof(mib[0]))
+ int ip_ttl, ip_forwarding;
+ struct ipstat ip_stat;
+ size_t needed;
+
+ if (!stats)
+ return ERROR_INVALID_PARAMETER;
+
+ needed = sizeof(ip_stat);
+ if(sysctl(mib, MIB_LEN, &ip_stat, &needed, NULL, 0) == -1)
+ {
+ ERR ("failed to get ipstat\n");
+ return ERROR_NOT_SUPPORTED;
+ }
+
+ needed = sizeof(ip_ttl);
+ if (sysctlbyname ("net.inet.ip.ttl", &ip_ttl, &needed, NULL, 0) == -1)
+ {
+ ERR ("failed to get ip Default TTL\n");
+ return ERROR_NOT_SUPPORTED;
+ }
+
+ needed = sizeof(ip_forwarding);
+ if (sysctlbyname ("net.inet.ip.forwarding", &ip_forwarding, &needed, NULL, 0) == -1)
+ {
+ ERR ("failed to get ip forwarding\n");
+ return ERROR_NOT_SUPPORTED;
+ }
+
+ stats->dwForwarding = ip_forwarding;
+ stats->dwDefaultTTL = ip_ttl;
+ stats->dwInDelivers = ip_stat.ips_delivered;
+ stats->dwInHdrErrors = ip_stat.ips_badhlen + ip_stat.ips_badsum + ip_stat.ips_tooshort + ip_stat.ips_badlen;
+ stats->dwInAddrErrors = ip_stat.ips_cantforward;
+ stats->dwInReceives = ip_stat.ips_total;
+ stats->dwForwDatagrams = ip_stat.ips_forward;
+ stats->dwInUnknownProtos = ip_stat.ips_noproto;
+ stats->dwInDiscards = ip_stat.ips_fragdropped;
+ stats->dwOutDiscards = ip_stat.ips_odropped;
+ stats->dwReasmOks = ip_stat.ips_reassembled;
+ stats->dwFragOks = ip_stat.ips_fragmented;
+ stats->dwFragFails = ip_stat.ips_cantfrag;
+ stats->dwReasmTimeout = ip_stat.ips_fragtimeout;
+ stats->dwOutNoRoutes = ip_stat.ips_noroute;
+ stats->dwOutRequests = ip_stat.ips_localout;
+ stats->dwReasmReqds = ip_stat.ips_fragments;
+
+ return NO_ERROR;
+#else
FILE *fp;
if (!stats)
@@ -493,6 +544,7 @@ DWORD getIPStats(PMIB_IPSTATS stats)
}
return NO_ERROR;
+#endif
}
DWORD getTCPStats(MIB_TCPSTATS *stats)
More information about the wine-cvs
mailing list