Fixed bug parsing /proc/net/arp for arp table.
This commit is contained in:
parent
b9ed79c965
commit
5cab2b3503
|
@ -27,9 +27,18 @@
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_NETINET_IN_H
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ARPA_INET_H
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
#if HAVE_NET_IF_H
|
#if HAVE_NET_IF_H
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_NET_IF_ARP_H
|
||||||
|
#include <net/if_arp.h>
|
||||||
|
#endif
|
||||||
#if HAVE_NETINET_TCP_H
|
#if HAVE_NETINET_TCP_H
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -664,20 +673,26 @@ PMIB_IPNETTABLE getArpTable(void)
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
char *endPtr;
|
char *endPtr;
|
||||||
|
|
||||||
if (ptr && *ptr) {
|
ret->table[ret->dwNumEntries].dwAddr = inet_addr(ptr);
|
||||||
ret->table[ret->dwNumEntries].dwAddr = strtoul(ptr, &endPtr, 16);
|
while (ptr && *ptr && !isspace(*ptr))
|
||||||
ptr = endPtr;
|
ptr++;
|
||||||
}
|
|
||||||
if (ptr && *ptr) {
|
if (ptr && *ptr) {
|
||||||
strtoul(ptr, &endPtr, 16); /* hw type (skip) */
|
strtoul(ptr, &endPtr, 16); /* hw type (skip) */
|
||||||
ptr = endPtr;
|
ptr = endPtr;
|
||||||
}
|
}
|
||||||
if (ptr && *ptr) {
|
if (ptr && *ptr) {
|
||||||
strtoul(ptr, &endPtr, 16); /* flags (skip) */
|
DWORD flags = strtoul(ptr, &endPtr, 16);
|
||||||
|
|
||||||
|
if (flags & ATF_COM)
|
||||||
|
ret->table[ret->dwNumEntries].dwType = MIB_IPNET_TYPE_DYNAMIC;
|
||||||
|
else if (flags & ATF_PERM)
|
||||||
|
ret->table[ret->dwNumEntries].dwType = MIB_IPNET_TYPE_STATIC;
|
||||||
|
else
|
||||||
|
ret->table[ret->dwNumEntries].dwType = MIB_IPNET_TYPE_OTHER;
|
||||||
|
|
||||||
ptr = endPtr;
|
ptr = endPtr;
|
||||||
}
|
}
|
||||||
/* FIXME: maybe this comes from flags? */
|
|
||||||
ret->table[ret->dwNumEntries].dwType = MIB_IPNET_TYPE_DYNAMIC;
|
|
||||||
while (ptr && *ptr && isspace(*ptr))
|
while (ptr && *ptr && isspace(*ptr))
|
||||||
ptr++;
|
ptr++;
|
||||||
while (ptr && *ptr && !isspace(*ptr)) {
|
while (ptr && *ptr && !isspace(*ptr)) {
|
||||||
|
|
Loading…
Reference in New Issue