diff --git a/configure b/configure index b9ef2193e1f..6dac855729b 100755 --- a/configure +++ b/configure @@ -7083,6 +7083,8 @@ done + + @@ -7092,6 +7094,7 @@ for ac_header in \ CoreAudio/CoreAudio.h \ DiskArbitration/DiskArbitration.h \ IOKit/IOKitLib.h \ + alias.h \ alsa/asoundlib.h \ arpa/inet.h \ arpa/nameser.h \ @@ -7135,6 +7138,7 @@ for ac_header in \ netdb.h \ netinet/in.h \ netinet/in_systm.h \ + netinet/ip_icmp.h \ netinet/tcp.h \ netinet/tcp_fsm.h \ netinet/udp.h \ @@ -7554,7 +7558,8 @@ done -for ac_header in netinet/tcp_var.h netinet/udp_var.h + +for ac_header in netinet/tcp_var.h netinet/udp_var.h netinet/icmp_var.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_header" >&5 @@ -7569,6 +7574,9 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include + #ifdef HAVE_ALIAS_H + # include + #endif #ifdef HAVE_SYS_SOCKET_H # include #endif @@ -7581,6 +7589,9 @@ cat >>conftest.$ac_ext <<_ACEOF #ifdef HAVE_NETINET_IP_VAR_H # include #endif + #ifdef HAVE_NETINET_IP_ICMP_H + # include + #endif #ifdef HAVE_NETINET_UDP_H # include #endif diff --git a/configure.ac b/configure.ac index 482c6ddef94..eb0479687b3 100644 --- a/configure.ac +++ b/configure.ac @@ -231,6 +231,7 @@ AC_CHECK_HEADERS(\ CoreAudio/CoreAudio.h \ DiskArbitration/DiskArbitration.h \ IOKit/IOKitLib.h \ + alias.h \ alsa/asoundlib.h \ arpa/inet.h \ arpa/nameser.h \ @@ -274,6 +275,7 @@ AC_CHECK_HEADERS(\ netdb.h \ netinet/in.h \ netinet/in_systm.h \ + netinet/ip_icmp.h \ netinet/tcp.h \ netinet/tcp_fsm.h \ netinet/udp.h \ @@ -360,8 +362,11 @@ AC_CHECK_HEADERS([netinet/in_pcb.h netinet/ip_var.h net/if.h net/if_arp.h net/if # include #endif]) -AC_CHECK_HEADERS([netinet/tcp_var.h netinet/udp_var.h],,, +AC_CHECK_HEADERS([netinet/tcp_var.h netinet/udp_var.h netinet/icmp_var.h],,, [#include + #ifdef HAVE_ALIAS_H + # include + #endif #ifdef HAVE_SYS_SOCKET_H # include #endif @@ -374,6 +379,9 @@ AC_CHECK_HEADERS([netinet/tcp_var.h netinet/udp_var.h],,, #ifdef HAVE_NETINET_IP_VAR_H # include #endif + #ifdef HAVE_NETINET_IP_ICMP_H + # include + #endif #ifdef HAVE_NETINET_UDP_H # include #endif diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c index 4cc7b523ebd..8d35c5facca 100644 --- a/dlls/iphlpapi/ipstats.c +++ b/dlls/iphlpapi/ipstats.c @@ -28,6 +28,9 @@ #include #include #include +#ifdef HAVE_ALIAS_H +#include +#endif #ifdef HAVE_SYS_SOCKET_H #include #endif @@ -65,6 +68,12 @@ #ifdef HAVE_NETINET_TCP_VAR_H #include #endif +#ifdef HAVE_NETINET_IP_ICMP_H +#include +#endif +#ifdef HAVE_NETINET_ICMP_VAR_H +#include +#endif #ifdef HAVE_NETINET_IP_VAR_H #include #endif @@ -247,6 +256,65 @@ DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry) DWORD getICMPStats(MIB_ICMP *stats) { +#if defined(HAVE_SYS_SYSCTL_H) && defined(ICMPCTL_STATS) + int mib[] = {CTL_NET, PF_INET, IPPROTO_ICMP, ICMPCTL_STATS}; +#define MIB_LEN (sizeof(mib) / sizeof(mib[0])) + size_t needed; + struct icmpstat icmp_stat; + int i; + + if (!stats) + return ERROR_INVALID_PARAMETER; + + needed = sizeof(icmp_stat); + if(sysctl(mib, MIB_LEN, &icmp_stat, &needed, NULL, 0) == -1) + { + ERR ("failed to get icmpstat\n"); + return ERROR_NOT_SUPPORTED; + } + + + /*in stats */ + stats->stats.icmpInStats.dwMsgs = icmp_stat.icps_badcode + icmp_stat.icps_checksum + icmp_stat.icps_tooshort + icmp_stat.icps_badlen; + for(i = 0; i <= ICMP_MAXTYPE; i++) + stats->stats.icmpInStats.dwMsgs += icmp_stat.icps_inhist[i]; + + stats->stats.icmpInStats.dwErrors = icmp_stat.icps_badcode + icmp_stat.icps_tooshort + icmp_stat.icps_checksum + icmp_stat.icps_badlen; + + stats->stats.icmpInStats.dwDestUnreachs = icmp_stat.icps_inhist[ICMP_UNREACH]; + stats->stats.icmpInStats.dwTimeExcds = icmp_stat.icps_inhist[ICMP_TIMXCEED]; + stats->stats.icmpInStats.dwParmProbs = icmp_stat.icps_inhist[ICMP_PARAMPROB]; + stats->stats.icmpInStats.dwSrcQuenchs = icmp_stat.icps_inhist[ICMP_SOURCEQUENCH]; + stats->stats.icmpInStats.dwRedirects = icmp_stat.icps_inhist[ICMP_REDIRECT]; + stats->stats.icmpInStats.dwEchos = icmp_stat.icps_inhist[ICMP_ECHO]; + stats->stats.icmpInStats.dwEchoReps = icmp_stat.icps_inhist[ICMP_ECHOREPLY]; + stats->stats.icmpInStats.dwTimestamps = icmp_stat.icps_inhist[ICMP_TSTAMP]; + stats->stats.icmpInStats.dwTimestampReps = icmp_stat.icps_inhist[ICMP_TSTAMPREPLY]; + stats->stats.icmpInStats.dwAddrMasks = icmp_stat.icps_inhist[ICMP_MASKREQ]; + stats->stats.icmpInStats.dwAddrMaskReps = icmp_stat.icps_inhist[ICMP_MASKREPLY]; + + + /* out stats */ + stats->stats.icmpOutStats.dwMsgs = icmp_stat.icps_oldshort + icmp_stat.icps_oldicmp; + for(i = 0; i <= ICMP_MAXTYPE; i++) + stats->stats.icmpOutStats.dwMsgs += icmp_stat.icps_outhist[i]; + + stats->stats.icmpOutStats.dwErrors = icmp_stat.icps_oldshort + icmp_stat.icps_oldicmp; + + stats->stats.icmpOutStats.dwDestUnreachs = icmp_stat.icps_outhist[ICMP_UNREACH]; + stats->stats.icmpOutStats.dwTimeExcds = icmp_stat.icps_outhist[ICMP_TIMXCEED]; + stats->stats.icmpOutStats.dwParmProbs = icmp_stat.icps_outhist[ICMP_PARAMPROB]; + stats->stats.icmpOutStats.dwSrcQuenchs = icmp_stat.icps_outhist[ICMP_SOURCEQUENCH]; + stats->stats.icmpOutStats.dwRedirects = icmp_stat.icps_outhist[ICMP_REDIRECT]; + stats->stats.icmpOutStats.dwEchos = icmp_stat.icps_outhist[ICMP_ECHO]; + stats->stats.icmpOutStats.dwEchoReps = icmp_stat.icps_outhist[ICMP_ECHOREPLY]; + stats->stats.icmpOutStats.dwTimestamps = icmp_stat.icps_outhist[ICMP_TSTAMP]; + stats->stats.icmpOutStats.dwTimestampReps = icmp_stat.icps_outhist[ICMP_TSTAMPREPLY]; + stats->stats.icmpOutStats.dwAddrMasks = icmp_stat.icps_outhist[ICMP_MASKREQ]; + stats->stats.icmpOutStats.dwAddrMaskReps = icmp_stat.icps_outhist[ICMP_MASKREPLY]; + + return NO_ERROR; +#else FILE *fp; if (!stats) @@ -376,6 +444,7 @@ DWORD getICMPStats(MIB_ICMP *stats) } return NO_ERROR; +#endif } DWORD getIPStats(PMIB_IPSTATS stats) diff --git a/include/config.h.in b/include/config.h.in index f9d27ae8bbf..9bef3c344c9 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -5,6 +5,9 @@ /* Specifies the compiler flag that forces a short wchar_t */ #undef CC_FLAG_SHORT_WCHAR +/* Define to 1 if you have the header file. */ +#undef HAVE_ALIAS_H + /* Define if you have ALSA 1.x including devel headers */ #undef HAVE_ALSA @@ -435,6 +438,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_ICMP_VAR_H + /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H @@ -444,6 +450,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_SYSTM_H +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IP_ICMP_H + /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IP_VAR_H