iphlpapi: Implement getUDPStats on FreeBSD.

oldstable
Eric Durbin 2008-06-24 22:44:13 -05:00 committed by Alexandre Julliard
parent 9a974dea63
commit 6d4eab9ab4
4 changed files with 55 additions and 2 deletions

11
configure vendored
View File

@ -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 <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IP_VAR_H
# include <netinet/ip_var.h>
#endif
#ifdef HAVE_NETINET_UDP_H
# include <netinet/udp.h>
#endif
#ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
#endif

View File

@ -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 <netinet/in.h>
#endif])
AC_CHECK_HEADERS([netinet/tcp_var.h],,,
AC_CHECK_HEADERS([netinet/tcp_var.h netinet/udp_var.h],,,
[#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
@ -370,6 +371,12 @@ AC_CHECK_HEADERS([netinet/tcp_var.h],,,
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IP_VAR_H
# include <netinet/ip_var.h>
#endif
#ifdef HAVE_NETINET_UDP_H
# include <netinet/udp.h>
#endif
#ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
#endif])

View File

@ -68,6 +68,12 @@
#ifdef HAVE_NETINET_IP_VAR_H
#include <netinet/ip_var.h>
#endif
#ifdef HAVE_NETINET_UDP_H
#include <netinet/udp.h>
#endif
#ifdef HAVE_NETINET_UDP_VAR_H
#include <netinet/udp_var.h>
#endif
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
@ -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)

View File

@ -456,6 +456,12 @@
/* Define to 1 if you have the <netinet/tcp_var.h> header file. */
#undef HAVE_NETINET_TCP_VAR_H
/* Define to 1 if you have the <netinet/udp.h> header file. */
#undef HAVE_NETINET_UDP_H
/* Define to 1 if you have the <netinet/udp_var.h> header file. */
#undef HAVE_NETINET_UDP_VAR_H
/* Define to 1 if you have the <netipx/ipx.h> header file. */
#undef HAVE_NETIPX_IPX_H