Eric Durbin : iphlpapi: Implement getNumArpEntries on FreeBSD.
Alexandre Julliard
julliard at winehq.org
Thu Jun 26 06:48:09 CDT 2008
Module: wine
Branch: master
Commit: 6ea3796cdb09c741eb37ab44842846d303b5bf69
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6ea3796cdb09c741eb37ab44842846d303b5bf69
Author: Eric Durbin <eadurbin at freebsd.org>
Date: Tue Jun 24 22:49:15 2008 -0500
iphlpapi: Implement getNumArpEntries on FreeBSD.
---
configure | 2 ++
configure.ac | 1 +
dlls/iphlpapi/ipstats.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
include/config.h.in | 3 +++
4 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index ca119ac..11d49ad 100755
--- a/configure
+++ b/configure
@@ -7088,6 +7088,7 @@ done
+
for ac_header in \
AudioUnit/AudioUnit.h \
Carbon/Carbon.h \
@@ -7136,6 +7137,7 @@ for ac_header in \
mntent.h \
ncurses.h \
netdb.h \
+ netinet/if_ether.h \
netinet/in.h \
netinet/in_systm.h \
netinet/ip_icmp.h \
diff --git a/configure.ac b/configure.ac
index 192dd03..c71427e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,6 +273,7 @@ AC_CHECK_HEADERS(\
mntent.h \
ncurses.h \
netdb.h \
+ netinet/if_ether.h \
netinet/in.h \
netinet/in_systm.h \
netinet/ip_icmp.h \
diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c
index 2b6c0f7..89ffa04 100644
--- a/dlls/iphlpapi/ipstats.c
+++ b/dlls/iphlpapi/ipstats.c
@@ -46,6 +46,9 @@
#ifdef HAVE_NET_IF_H
#include <net/if.h>
#endif
+#ifdef HAVE_NET_IF_DL_H
+#include <net/if_dl.h>
+#endif
#ifdef HAVE_NET_IF_TYPES_H
#include <net/if_types.h>
#endif
@@ -55,6 +58,9 @@
#ifdef HAVE_NET_IF_ARP_H
#include <net/if_arp.h>
#endif
+#ifdef HAVE_NETINET_IF_ETHER_H
+#include <netinet/if_ether.h>
+#endif
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif
@@ -1234,6 +1240,46 @@ DWORD getRouteTable(PMIB_IPFORWARDTABLE *ppIpForwardTable, HANDLE heap,
DWORD getNumArpEntries(void)
{
+#if defined(HAVE_SYS_SYSCTL_H) && defined(NET_RT_DUMP)
+ int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, RTF_LLINFO};
+#define MIB_LEN (sizeof(mib) / sizeof(mib[0]))
+ DWORD arpEntries = 0;
+ size_t needed;
+ char *buf, *lim, *next;
+ struct rt_msghdr *rtm;
+ struct sockaddr_inarp *sinarp;
+ struct sockaddr_dl *sdl;
+
+ if (sysctl (mib, MIB_LEN, NULL, &needed, NULL, 0) == -1)
+ {
+ ERR ("failed to get size of arp table\n");
+ return 0;
+ }
+
+ buf = HeapAlloc (GetProcessHeap (), 0, needed);
+ if (!buf) return 0;
+
+ if (sysctl (mib, MIB_LEN, buf, &needed, NULL, 0) == -1)
+ {
+ ERR ("failed to get arp table\n");
+ HeapFree (GetProcessHeap (), 0, buf);
+ return 0;
+ }
+
+ lim = buf + needed;
+ next = buf;
+ while(next < lim)
+ {
+ rtm = (struct rt_msghdr *)next;
+ sinarp=(struct sockaddr_inarp *)(rtm + 1);
+ sdl = (struct sockaddr_dl *)((char *)sinarp + ROUNDUP(sinarp->sin_len));
+ if(sdl->sdl_alen) /* arp entry */
+ arpEntries++;
+ next += rtm->rtm_msglen;
+ }
+ HeapFree (GetProcessHeap (), 0, buf);
+ return arpEntries;
+#endif
return getNumWithOneHeader("/proc/net/arp");
}
diff --git a/include/config.h.in b/include/config.h.in
index 40f62a9..63e8e89 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -441,6 +441,9 @@
/* 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/if_ether.h> header file. */
+#undef HAVE_NETINET_IF_ETHER_H
+
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
More information about the wine-cvs
mailing list