[2/3] iphlpapi: Check for the right IP statistics structure name (for DragonFly BSD)

André Hentschel nerv at dawncrow.de
Sat Jun 2 11:58:39 CDT 2012


it's ip_stats on at least DragonFly and ipstat on at least FreeBSD, not sure about OpenBSD or NetBSD, but i guess they use one of them, too.
---
 configure.ac            |   12 ++++++++++++
 dlls/iphlpapi/ipstats.c |    6 +++++-
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index f7701e2..d085459 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2312,6 +2312,18 @@ AC_CHECK_MEMBERS([struct icmpstat.icps_outhist],,,
 #include <netinet/icmp_var.h>
 #endif])
 
+dnl Check for struct ipstat
+AC_CHECK_MEMBERS([struct ipstat.ips_total],,,
+[#ifdef HAVE_NETINET_IP_VAR_H
+#include <netinet/ip_var.h>
+#endif])
+
+dnl Check for struct ip_stats
+AC_CHECK_MEMBERS([struct ip_stats.ips_total],,,
+[#ifdef HAVE_NETINET_IP_VAR_H
+#include <netinet/ip_var.h>
+#endif])
+
 dnl Check for struct ifreq.ifr_hwaddr
 AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr],,,
 [#ifdef HAVE_SYS_TYPES_H
diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c
index c204223..9b4b76b 100644
--- a/dlls/iphlpapi/ipstats.c
+++ b/dlls/iphlpapi/ipstats.c
@@ -659,12 +659,16 @@ DWORD WINAPI GetIpStatistics(PMIB_IPSTATS stats)
         }
         if (kc) kstat_close( kc );
     }
-#elif defined(HAVE_SYS_SYSCTL_H) && defined(IPCTL_STATS)
+#elif defined(HAVE_SYS_SYSCTL_H) && defined(IPCTL_STATS) && (HAVE_STRUCT_IPSTAT_IPS_TOTAL || HAVE_STRUCT_IP_STATS_IPS_TOTAL)
     {
         int mib[] = {CTL_NET, PF_INET, IPPROTO_IP, IPCTL_STATS};
 #define MIB_LEN (sizeof(mib) / sizeof(mib[0]))
         int ip_ttl, ip_forwarding;
+#if HAVE_STRUCT_IPSTAT_IPS_TOTAL
         struct ipstat ip_stat;
+#elif HAVE_STRUCT_IP_STATS_IPS_TOTAL
+        struct ip_stats ip_stat;
+#endif
         size_t needed;
 
         needed = sizeof(ip_stat);
-- 

Best Regards, André Hentschel


More information about the wine-patches mailing list