iphlpapi: Implement getTCPStats on FreeBSD.

This commit is contained in:
Eric Durbin 2008-06-24 22:47:33 -05:00 committed by Alexandre Julliard
parent 3d122aec41
commit beea4d3006
5 changed files with 50 additions and 2 deletions

3
configure vendored
View File

@ -7559,7 +7559,8 @@ done
for ac_header in netinet/tcp_var.h netinet/udp_var.h netinet/icmp_var.h
for ac_header in netinet/tcp_var.h netinet/udp_var.h netinet/icmp_var.h netinet/tcp_timer.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_header" >&5

View File

@ -362,7 +362,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 netinet/udp_var.h netinet/icmp_var.h],,,
AC_CHECK_HEADERS([netinet/tcp_var.h netinet/udp_var.h netinet/icmp_var.h netinet/tcp_timer.h ],,,
[#include <sys/types.h>
#ifdef HAVE_ALIAS_H
# include <alias.h>

View File

@ -68,6 +68,9 @@
#ifdef HAVE_NETINET_TCP_VAR_H
#include <netinet/tcp_var.h>
#endif
#ifdef HAVE_NETINET_TCP_TIMER_H
#include <netinet/tcp_timer.h>
#endif
#ifdef HAVE_NETINET_IP_ICMP_H
#include <netinet/ip_icmp.h>
#endif
@ -618,6 +621,42 @@ DWORD getIPStats(PMIB_IPSTATS stats)
DWORD getTCPStats(MIB_TCPSTATS *stats)
{
#if defined(HAVE_SYS_SYSCTL_H) && defined(UDPCTL_STATS)
int mib[] = {CTL_NET, PF_INET, IPPROTO_TCP, TCPCTL_STATS};
#define MIB_LEN (sizeof(mib) / sizeof(mib[0]))
#define hz 1000
struct tcpstat tcp_stat;
size_t needed;
if (!stats)
return ERROR_INVALID_PARAMETER;
needed = sizeof(tcp_stat);
if(sysctl(mib, MIB_LEN, &tcp_stat, &needed, NULL, 0) == -1)
{
ERR ("failed to get tcpstat\n");
return ERROR_NOT_SUPPORTED;
}
stats->dwRtoAlgorithm = MIB_TCP_RTO_VANJ;
stats->dwRtoMin = TCPTV_MIN;
stats->dwRtoMax = TCPTV_REXMTMAX;
stats->dwMaxConn = -1;
stats->dwActiveOpens = tcp_stat.tcps_connattempt;
stats->dwPassiveOpens = tcp_stat.tcps_accepts;
stats->dwAttemptFails = tcp_stat.tcps_conndrops;
stats->dwEstabResets = tcp_stat.tcps_drops;
stats->dwCurrEstab = 0;
stats->dwInSegs = tcp_stat.tcps_rcvtotal;
stats->dwOutSegs = tcp_stat.tcps_sndtotal - tcp_stat.tcps_sndrexmitpack;
stats->dwRetransSegs = tcp_stat.tcps_sndrexmitpack;
stats->dwInErrs = tcp_stat.tcps_rcvbadsum + tcp_stat.tcps_rcvbadoff + tcp_stat.tcps_rcvmemdrop + tcp_stat.tcps_rcvshort;
stats->dwOutRsts = tcp_stat.tcps_sndctrl - tcp_stat.tcps_closed;
stats->dwNumConns = tcp_stat.tcps_connects;
return NO_ERROR;
#else
FILE *fp;
if (!stats)
@ -710,6 +749,7 @@ DWORD getTCPStats(MIB_TCPSTATS *stats)
}
return NO_ERROR;
#endif
}
DWORD getUDPStats(MIB_UDPSTATS *stats)

View File

@ -462,6 +462,9 @@
/* Define to 1 if you have the <netinet/tcp.h> header file. */
#undef HAVE_NETINET_TCP_H
/* Define to 1 if you have the <netinet/tcp_timer.h> header file. */
#undef HAVE_NETINET_TCP_TIMER_H
/* Define to 1 if you have the <netinet/tcp_var.h> header file. */
#undef HAVE_NETINET_TCP_VAR_H

View File

@ -261,6 +261,10 @@ typedef struct _MIB_IPNETROW
DWORD dwType;
} MIB_IPNETROW, *PMIB_IPNETROW;
#define MIB_TCP_RTO_OTHER 1
#define MIB_TCP_RTO_CONSTANT 2
#define MIB_TCP_RTO_RSRE 3
#define MIB_TCP_RTO_VANJ 4
#define MIB_IPNET_TYPE_OTHER 1
#define MIB_IPNET_TYPE_INVALID 2
#define MIB_IPNET_TYPE_DYNAMIC 3