summaryrefslogtreecommitdiff
path: root/src/arp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arp.c')
-rw-r--r--src/arp.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/arp.c b/src/arp.c
index 8beaed4..3329d6d 100644
--- a/src/arp.c
+++ b/src/arp.c
@@ -1,4 +1,4 @@
-/* dnsmasq is Copyright (c) 2000-2018 Simon Kelley
+/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@ struct arp_record {
unsigned short hwlen, status;
int family;
unsigned char hwaddr[DHCP_CHADDR_MAX];
- struct all_addr addr;
+ union all_addr addr;
struct arp_record *next;
};
@@ -44,11 +44,6 @@ static int filter_mac(int family, char *addrp, char *mac, size_t maclen, void *p
if (maclen > DHCP_CHADDR_MAX)
return 1;
-#ifndef HAVE_IPV6
- if (family != AF_INET)
- return 1;
-#endif
-
/* Look for existing entry */
for (arp = arps; arp; arp = arp->next)
{
@@ -57,16 +52,14 @@ static int filter_mac(int family, char *addrp, char *mac, size_t maclen, void *p
if (family == AF_INET)
{
- if (arp->addr.addr.addr4.s_addr != ((struct in_addr *)addrp)->s_addr)
+ if (arp->addr.addr4.s_addr != ((struct in_addr *)addrp)->s_addr)
continue;
}
-#ifdef HAVE_IPV6
else
{
- if (!IN6_ARE_ADDR_EQUAL(&arp->addr.addr.addr6, (struct in6_addr *)addrp))
+ if (!IN6_ARE_ADDR_EQUAL(&arp->addr.addr6, (struct in6_addr *)addrp))
continue;
}
-#endif
if (arp->status == ARP_EMPTY)
{
@@ -102,11 +95,9 @@ static int filter_mac(int family, char *addrp, char *mac, size_t maclen, void *p
arp->family = family;
memcpy(arp->hwaddr, mac, maclen);
if (family == AF_INET)
- arp->addr.addr.addr4.s_addr = ((struct in_addr *)addrp)->s_addr;
-#ifdef HAVE_IPV6
+ arp->addr.addr4.s_addr = ((struct in_addr *)addrp)->s_addr;
else
- memcpy(&arp->addr.addr.addr6, addrp, IN6ADDRSZ);
-#endif
+ memcpy(&arp->addr.addr6, addrp, IN6ADDRSZ);
}
return 1;
@@ -133,14 +124,12 @@ int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now)
continue;
if (arp->family == AF_INET &&
- arp->addr.addr.addr4.s_addr != addr->in.sin_addr.s_addr)
+ arp->addr.addr4.s_addr != addr->in.sin_addr.s_addr)
continue;
-#ifdef HAVE_IPV6
if (arp->family == AF_INET6 &&
- !IN6_ARE_ADDR_EQUAL(&arp->addr.addr.addr6, &addr->in6.sin6_addr))
+ !IN6_ARE_ADDR_EQUAL(&arp->addr.addr6, &addr->in6.sin6_addr))
continue;
-#endif
/* Only accept positive entries unless in lazy mode. */
if (arp->status != ARP_EMPTY || lazy || updated)
@@ -202,11 +191,9 @@ int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now)
arp->hwlen = 0;
if (addr->sa.sa_family == AF_INET)
- arp->addr.addr.addr4.s_addr = addr->in.sin_addr.s_addr;
-#ifdef HAVE_IPV6
+ arp->addr.addr4.s_addr = addr->in.sin_addr.s_addr;
else
- memcpy(&arp->addr.addr.addr6, &addr->in6.sin6_addr, IN6ADDRSZ);
-#endif
+ memcpy(&arp->addr.addr6, &addr->in6.sin6_addr, IN6ADDRSZ);
}
return 0;