iphlpapi: Implement getNumArpEntries on FreeBSD.
This commit is contained in:
parent
beea4d3006
commit
6ea3796cdb
|
@ -7086,6 +7086,7 @@ done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ac_header in \
|
for ac_header in \
|
||||||
|
@ -7136,6 +7137,7 @@ for ac_header in \
|
||||||
mntent.h \
|
mntent.h \
|
||||||
ncurses.h \
|
ncurses.h \
|
||||||
netdb.h \
|
netdb.h \
|
||||||
|
netinet/if_ether.h \
|
||||||
netinet/in.h \
|
netinet/in.h \
|
||||||
netinet/in_systm.h \
|
netinet/in_systm.h \
|
||||||
netinet/ip_icmp.h \
|
netinet/ip_icmp.h \
|
||||||
|
|
|
@ -273,6 +273,7 @@ AC_CHECK_HEADERS(\
|
||||||
mntent.h \
|
mntent.h \
|
||||||
ncurses.h \
|
ncurses.h \
|
||||||
netdb.h \
|
netdb.h \
|
||||||
|
netinet/if_ether.h \
|
||||||
netinet/in.h \
|
netinet/in.h \
|
||||||
netinet/in_systm.h \
|
netinet/in_systm.h \
|
||||||
netinet/ip_icmp.h \
|
netinet/ip_icmp.h \
|
||||||
|
|
|
@ -46,6 +46,9 @@
|
||||||
#ifdef HAVE_NET_IF_H
|
#ifdef HAVE_NET_IF_H
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_NET_IF_DL_H
|
||||||
|
#include <net/if_dl.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_NET_IF_TYPES_H
|
#ifdef HAVE_NET_IF_TYPES_H
|
||||||
#include <net/if_types.h>
|
#include <net/if_types.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,6 +58,9 @@
|
||||||
#ifdef HAVE_NET_IF_ARP_H
|
#ifdef HAVE_NET_IF_ARP_H
|
||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_NETINET_IF_ETHER_H
|
||||||
|
#include <netinet/if_ether.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_NETINET_TCP_H
|
#ifdef HAVE_NETINET_TCP_H
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1234,6 +1240,46 @@ DWORD getRouteTable(PMIB_IPFORWARDTABLE *ppIpForwardTable, HANDLE heap,
|
||||||
|
|
||||||
DWORD getNumArpEntries(void)
|
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");
|
return getNumWithOneHeader("/proc/net/arp");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -441,6 +441,9 @@
|
||||||
/* Define to 1 if you have the <netinet/icmp_var.h> header file. */
|
/* Define to 1 if you have the <netinet/icmp_var.h> header file. */
|
||||||
#undef HAVE_NETINET_ICMP_VAR_H
|
#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. */
|
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||||
#undef HAVE_NETINET_IN_H
|
#undef HAVE_NETINET_IN_H
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue