Fixed bug parsing /proc/net/arp for arp table.

This commit is contained in:
Juan Lang 2003-09-02 00:55:48 +00:00 committed by Alexandre Julliard
parent b9ed79c965
commit 5cab2b3503
1 changed files with 23 additions and 8 deletions

View File

@ -25,11 +25,20 @@
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#include <sys/socket.h>
#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
#include <net/if.h>
#endif
#if HAVE_NET_IF_ARP_H
#include <net/if_arp.h>
#endif
#if HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif
@ -664,20 +673,26 @@ PMIB_IPNETTABLE getArpTable(void)
if (ptr) {
char *endPtr;
if (ptr && *ptr) {
ret->table[ret->dwNumEntries].dwAddr = strtoul(ptr, &endPtr, 16);
ptr = endPtr;
}
ret->table[ret->dwNumEntries].dwAddr = inet_addr(ptr);
while (ptr && *ptr && !isspace(*ptr))
ptr++;
if (ptr && *ptr) {
strtoul(ptr, &endPtr, 16); /* hw type (skip) */
ptr = endPtr;
}
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;
}
/* FIXME: maybe this comes from flags? */
ret->table[ret->dwNumEntries].dwType = MIB_IPNET_TYPE_DYNAMIC;
while (ptr && *ptr && isspace(*ptr))
ptr++;
while (ptr && *ptr && !isspace(*ptr)) {