diff --git a/configure b/configure index e85507660ba..b9ef2193e1f 100755 --- a/configure +++ b/configure @@ -7083,6 +7083,7 @@ done + for ac_header in \ @@ -7136,6 +7137,7 @@ for ac_header in \ netinet/in_systm.h \ netinet/tcp.h \ netinet/tcp_fsm.h \ + netinet/udp.h \ openssl/err.h \ openssl/ssl.h \ png.h \ @@ -7551,7 +7553,8 @@ done -for ac_header in netinet/tcp_var.h + +for ac_header in netinet/tcp_var.h netinet/udp_var.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_header" >&5 @@ -7575,6 +7578,12 @@ cat >>conftest.$ac_ext <<_ACEOF #ifdef HAVE_NETINET_IN_H # include #endif + #ifdef HAVE_NETINET_IP_VAR_H + # include + #endif + #ifdef HAVE_NETINET_UDP_H + # include + #endif #ifdef HAVE_NETINET_TCP_H # include #endif diff --git a/configure.ac b/configure.ac index 77287dec802..482c6ddef94 100644 --- a/configure.ac +++ b/configure.ac @@ -276,6 +276,7 @@ AC_CHECK_HEADERS(\ netinet/in_systm.h \ netinet/tcp.h \ netinet/tcp_fsm.h \ + netinet/udp.h \ openssl/err.h \ openssl/ssl.h \ png.h \ @@ -359,7 +360,7 @@ 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],,, +AC_CHECK_HEADERS([netinet/tcp_var.h netinet/udp_var.h],,, [#include #ifdef HAVE_SYS_SOCKET_H # include @@ -370,6 +371,12 @@ AC_CHECK_HEADERS([netinet/tcp_var.h],,, #ifdef HAVE_NETINET_IN_H # include #endif + #ifdef HAVE_NETINET_IP_VAR_H + # include + #endif + #ifdef HAVE_NETINET_UDP_H + # include + #endif #ifdef HAVE_NETINET_TCP_H # include #endif]) diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c index fa2826df196..772006b9d57 100644 --- a/dlls/iphlpapi/ipstats.c +++ b/dlls/iphlpapi/ipstats.c @@ -68,6 +68,12 @@ #ifdef HAVE_NETINET_IP_VAR_H #include #endif +#ifdef HAVE_NETINET_UDP_H +#include +#endif +#ifdef HAVE_NETINET_UDP_VAR_H +#include +#endif #ifdef HAVE_SYS_SYSCTL_H #include @@ -587,6 +593,30 @@ DWORD getTCPStats(MIB_TCPSTATS *stats) DWORD getUDPStats(MIB_UDPSTATS *stats) { +#if defined(HAVE_SYS_SYSCTL_H) && defined(UDPCTL_STATS) + int mib[] = {CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_STATS}; +#define MIB_LEN (sizeof(mib) / sizeof(mib[0])) + struct udpstat udp_stat; + size_t needed; + if (!stats) + return ERROR_INVALID_PARAMETER; + + needed = sizeof(udp_stat); + + if(sysctl(mib, MIB_LEN, &udp_stat, &needed, NULL, 0) == -1) + { + ERR ("failed to get udpstat\n"); + return ERROR_NOT_SUPPORTED; + } + + stats->dwInDatagrams = udp_stat.udps_ipackets; + stats->dwOutDatagrams = udp_stat.udps_opackets; + stats->dwNoPorts = udp_stat.udps_noport; + stats->dwInErrors = udp_stat.udps_hdrops + udp_stat.udps_badsum + udp_stat.udps_fullsock + udp_stat.udps_badlen; + stats->dwNumAddrs = getNumUdpEntries(); + + return NO_ERROR; +#else FILE *fp; if (!stats) @@ -642,6 +672,7 @@ DWORD getUDPStats(MIB_UDPSTATS *stats) } return NO_ERROR; +#endif } static DWORD getNumWithOneHeader(const char *filename) diff --git a/include/config.h.in b/include/config.h.in index 9833b2387a8..f9d27ae8bbf 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -456,6 +456,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_VAR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_UDP_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_UDP_VAR_H + /* Define to 1 if you have the header file. */ #undef HAVE_NETIPX_IPX_H