Commit 6ea3796c authored by Eric Durbin's avatar Eric Durbin Committed by Alexandre Julliard

iphlpapi: Implement getNumArpEntries on FreeBSD.

parent beea4d30
......@@ -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 \
......
......@@ -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 \
......
......@@ -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");
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment