iphlpapi: Implement getICMPStats on FreeBSD.

This commit is contained in:
Eric Durbin 2008-06-24 22:45:51 -05:00 committed by Alexandre Julliard
parent 9d4c42a5b7
commit 020b0ef64f
4 changed files with 99 additions and 2 deletions

13
configure vendored
View File

@ -7083,6 +7083,8 @@ done
@ -7092,6 +7094,7 @@ for ac_header in \
CoreAudio/CoreAudio.h \ CoreAudio/CoreAudio.h \
DiskArbitration/DiskArbitration.h \ DiskArbitration/DiskArbitration.h \
IOKit/IOKitLib.h \ IOKit/IOKitLib.h \
alias.h \
alsa/asoundlib.h \ alsa/asoundlib.h \
arpa/inet.h \ arpa/inet.h \
arpa/nameser.h \ arpa/nameser.h \
@ -7135,6 +7138,7 @@ for ac_header in \
netdb.h \ netdb.h \
netinet/in.h \ netinet/in.h \
netinet/in_systm.h \ netinet/in_systm.h \
netinet/ip_icmp.h \
netinet/tcp.h \ netinet/tcp.h \
netinet/tcp_fsm.h \ netinet/tcp_fsm.h \
netinet/udp.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 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
@ -7569,6 +7574,9 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */ /* end confdefs.h. */
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_ALIAS_H
# include <alias.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
@ -7581,6 +7589,9 @@ cat >>conftest.$ac_ext <<_ACEOF
#ifdef HAVE_NETINET_IP_VAR_H #ifdef HAVE_NETINET_IP_VAR_H
# include <netinet/ip_var.h> # include <netinet/ip_var.h>
#endif #endif
#ifdef HAVE_NETINET_IP_ICMP_H
# include <netinet/ip_icmp.h>
#endif
#ifdef HAVE_NETINET_UDP_H #ifdef HAVE_NETINET_UDP_H
# include <netinet/udp.h> # include <netinet/udp.h>
#endif #endif

View File

@ -231,6 +231,7 @@ AC_CHECK_HEADERS(\
CoreAudio/CoreAudio.h \ CoreAudio/CoreAudio.h \
DiskArbitration/DiskArbitration.h \ DiskArbitration/DiskArbitration.h \
IOKit/IOKitLib.h \ IOKit/IOKitLib.h \
alias.h \
alsa/asoundlib.h \ alsa/asoundlib.h \
arpa/inet.h \ arpa/inet.h \
arpa/nameser.h \ arpa/nameser.h \
@ -274,6 +275,7 @@ AC_CHECK_HEADERS(\
netdb.h \ netdb.h \
netinet/in.h \ netinet/in.h \
netinet/in_systm.h \ netinet/in_systm.h \
netinet/ip_icmp.h \
netinet/tcp.h \ netinet/tcp.h \
netinet/tcp_fsm.h \ netinet/tcp_fsm.h \
netinet/udp.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 <netinet/in.h> # include <netinet/in.h>
#endif]) #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 <sys/types.h> [#include <sys/types.h>
#ifdef HAVE_ALIAS_H
# include <alias.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
@ -374,6 +379,9 @@ AC_CHECK_HEADERS([netinet/tcp_var.h netinet/udp_var.h],,,
#ifdef HAVE_NETINET_IP_VAR_H #ifdef HAVE_NETINET_IP_VAR_H
# include <netinet/ip_var.h> # include <netinet/ip_var.h>
#endif #endif
#ifdef HAVE_NETINET_IP_ICMP_H
# include <netinet/ip_icmp.h>
#endif
#ifdef HAVE_NETINET_UDP_H #ifdef HAVE_NETINET_UDP_H
# include <netinet/udp.h> # include <netinet/udp.h>
#endif #endif

View File

@ -28,6 +28,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_ALIAS_H
#include <alias.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
@ -65,6 +68,12 @@
#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_IP_ICMP_H
#include <netinet/ip_icmp.h>
#endif
#ifdef HAVE_NETINET_ICMP_VAR_H
#include <netinet/icmp_var.h>
#endif
#ifdef HAVE_NETINET_IP_VAR_H #ifdef HAVE_NETINET_IP_VAR_H
#include <netinet/ip_var.h> #include <netinet/ip_var.h>
#endif #endif
@ -247,6 +256,65 @@ DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry)
DWORD getICMPStats(MIB_ICMP *stats) 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; FILE *fp;
if (!stats) if (!stats)
@ -376,6 +444,7 @@ DWORD getICMPStats(MIB_ICMP *stats)
} }
return NO_ERROR; return NO_ERROR;
#endif
} }
DWORD getIPStats(PMIB_IPSTATS stats) DWORD getIPStats(PMIB_IPSTATS stats)

View File

@ -5,6 +5,9 @@
/* Specifies the compiler flag that forces a short wchar_t */ /* Specifies the compiler flag that forces a short wchar_t */
#undef CC_FLAG_SHORT_WCHAR #undef CC_FLAG_SHORT_WCHAR
/* Define to 1 if you have the <alias.h> header file. */
#undef HAVE_ALIAS_H
/* Define if you have ALSA 1.x including devel headers */ /* Define if you have ALSA 1.x including devel headers */
#undef HAVE_ALSA #undef HAVE_ALSA
@ -435,6 +438,9 @@
/* Define to 1 if you have the <netdb.h> header file. */ /* Define to 1 if you have the <netdb.h> header file. */
#undef HAVE_NETDB_H #undef HAVE_NETDB_H
/* Define to 1 if you have the <netinet/icmp_var.h> header file. */
#undef HAVE_NETINET_ICMP_VAR_H
/* Define to 1 if you have the <netinet/in.h> header file. */ /* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H #undef HAVE_NETINET_IN_H
@ -444,6 +450,9 @@
/* Define to 1 if you have the <netinet/in_systm.h> header file. */ /* Define to 1 if you have the <netinet/in_systm.h> header file. */
#undef HAVE_NETINET_IN_SYSTM_H #undef HAVE_NETINET_IN_SYSTM_H
/* Define to 1 if you have the <netinet/ip_icmp.h> header file. */
#undef HAVE_NETINET_IP_ICMP_H
/* Define to 1 if you have the <netinet/ip_var.h> header file. */ /* Define to 1 if you have the <netinet/ip_var.h> header file. */
#undef HAVE_NETINET_IP_VAR_H #undef HAVE_NETINET_IP_VAR_H