From eaab7a88f4e52b3630a21db183cea2a0d21e6fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Hentschel?= Date: Sun, 3 Jun 2012 14:32:20 +0200 Subject: [PATCH] iphlpapi: Check for the right TCP statistics structure name (for DragonFly BSD). --- configure | 28 ++++++++++++++++++++++++++++ configure.ac | 12 ++++++++++++ dlls/iphlpapi/ipstats.c | 6 +++++- include/config.h.in | 6 ++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 0add6369db..e8201d3179 100755 --- a/configure +++ b/configure @@ -14086,6 +14086,34 @@ _ACEOF fi +ac_fn_c_check_member "$LINENO" "struct tcpstat" "tcps_connattempt" "ac_cv_member_struct_tcpstat_tcps_connattempt" "#ifdef HAVE_NETINET_TCP_VAR_H +#include +#endif +" +if test "x$ac_cv_member_struct_tcpstat_tcps_connattempt" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TCPSTAT_TCPS_CONNATTEMPT 1 +_ACEOF + + +fi + + +ac_fn_c_check_member "$LINENO" "struct tcp_stats" "tcps_connattempt" "ac_cv_member_struct_tcp_stats_tcps_connattempt" "#ifdef HAVE_NETINET_TCP_VAR_H +#include +#endif +" +if test "x$ac_cv_member_struct_tcp_stats_tcps_connattempt" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TCP_STATS_TCPS_CONNATTEMPT 1 +_ACEOF + + +fi + + ac_fn_c_check_member "$LINENO" "struct ifreq" "ifr_hwaddr" "ac_cv_member_struct_ifreq_ifr_hwaddr" "#ifdef HAVE_SYS_TYPES_H #include #endif diff --git a/configure.ac b/configure.ac index d085459f88..d1acb72a58 100644 --- a/configure.ac +++ b/configure.ac @@ -2324,6 +2324,18 @@ AC_CHECK_MEMBERS([struct ip_stats.ips_total],,, #include #endif]) +dnl Check for struct tcpstat +AC_CHECK_MEMBERS([struct tcpstat.tcps_connattempt],,, +[#ifdef HAVE_NETINET_TCP_VAR_H +#include +#endif]) + +dnl Check for struct tcp_stats +AC_CHECK_MEMBERS([struct tcp_stats.tcps_connattempt],,, +[#ifdef HAVE_NETINET_TCP_VAR_H +#include +#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 9b4b76b120..41cb7797db 100644 --- a/dlls/iphlpapi/ipstats.c +++ b/dlls/iphlpapi/ipstats.c @@ -812,7 +812,7 @@ DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS stats) } if (kc) kstat_close( kc ); } -#elif defined(HAVE_SYS_SYSCTL_H) && defined(UDPCTL_STATS) +#elif defined(HAVE_SYS_SYSCTL_H) && defined(TCPCTL_STATS) && (HAVE_STRUCT_TCPSTAT_TCPS_CONNATTEMPT || HAVE_STRUCT_TCP_STATS_TCPS_CONNATTEMPT) { #ifndef TCPTV_MIN /* got removed in Mac OS X for some reason */ #define TCPTV_MIN 2 @@ -821,7 +821,11 @@ DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS stats) int mib[] = {CTL_NET, PF_INET, IPPROTO_TCP, TCPCTL_STATS}; #define MIB_LEN (sizeof(mib) / sizeof(mib[0])) #define hz 1000 +#if HAVE_STRUCT_TCPSTAT_TCPS_CONNATTEMPT struct tcpstat tcp_stat; +#elif HAVE_STRUCT_TCP_STATS_TCPS_CONNATTEMPT + struct tcp_stats tcp_stat; +#endif size_t needed = sizeof(tcp_stat); if(sysctl(mib, MIB_LEN, &tcp_stat, &needed, NULL, 0) != -1) diff --git a/include/config.h.in b/include/config.h.in index bdcb1993d7..c4b67a0e61 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -857,6 +857,12 @@ /* Define to 1 if `st_mtim' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_MTIM +/* Define to 1 if `tcps_connattempt' is a member of `struct tcpstat'. */ +#undef HAVE_STRUCT_TCPSTAT_TCPS_CONNATTEMPT + +/* Define to 1 if `tcps_connattempt' is a member of `struct tcp_stats'. */ +#undef HAVE_STRUCT_TCP_STATS_TCPS_CONNATTEMPT + /* Define to 1 if the system has the type `struct xinpgen'. */ #undef HAVE_STRUCT_XINPGEN