iphlpapi: Implement getTCPStats on FreeBSD.
This commit is contained in:
parent
3d122aec41
commit
beea4d3006
|
@ -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
|
do
|
||||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||||
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
|
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
|
||||||
|
|
|
@ -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>
|
# include <netinet/in.h>
|
||||||
#endif])
|
#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>
|
[#include <sys/types.h>
|
||||||
#ifdef HAVE_ALIAS_H
|
#ifdef HAVE_ALIAS_H
|
||||||
# include <alias.h>
|
# include <alias.h>
|
||||||
|
|
|
@ -68,6 +68,9 @@
|
||||||
#ifdef HAVE_NETINET_TCP_VAR_H
|
#ifdef HAVE_NETINET_TCP_VAR_H
|
||||||
#include <netinet/tcp_var.h>
|
#include <netinet/tcp_var.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_NETINET_TCP_TIMER_H
|
||||||
|
#include <netinet/tcp_timer.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_NETINET_IP_ICMP_H
|
#ifdef HAVE_NETINET_IP_ICMP_H
|
||||||
#include <netinet/ip_icmp.h>
|
#include <netinet/ip_icmp.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -618,6 +621,42 @@ DWORD getIPStats(PMIB_IPSTATS stats)
|
||||||
|
|
||||||
DWORD getTCPStats(MIB_TCPSTATS *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;
|
FILE *fp;
|
||||||
|
|
||||||
if (!stats)
|
if (!stats)
|
||||||
|
@ -710,6 +749,7 @@ DWORD getTCPStats(MIB_TCPSTATS *stats)
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD getUDPStats(MIB_UDPSTATS *stats)
|
DWORD getUDPStats(MIB_UDPSTATS *stats)
|
||||||
|
|
|
@ -462,6 +462,9 @@
|
||||||
/* Define to 1 if you have the <netinet/tcp.h> header file. */
|
/* Define to 1 if you have the <netinet/tcp.h> header file. */
|
||||||
#undef HAVE_NETINET_TCP_H
|
#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. */
|
/* Define to 1 if you have the <netinet/tcp_var.h> header file. */
|
||||||
#undef HAVE_NETINET_TCP_VAR_H
|
#undef HAVE_NETINET_TCP_VAR_H
|
||||||
|
|
||||||
|
|
|
@ -261,6 +261,10 @@ typedef struct _MIB_IPNETROW
|
||||||
DWORD dwType;
|
DWORD dwType;
|
||||||
} MIB_IPNETROW, *PMIB_IPNETROW;
|
} 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_OTHER 1
|
||||||
#define MIB_IPNET_TYPE_INVALID 2
|
#define MIB_IPNET_TYPE_INVALID 2
|
||||||
#define MIB_IPNET_TYPE_DYNAMIC 3
|
#define MIB_IPNET_TYPE_DYNAMIC 3
|
||||||
|
|
Loading…
Reference in New Issue