mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-30 18:07:52 +00:00
spotfilter: use ARP as fallback for IP discovery
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -13,6 +13,7 @@ struct cache_entry {
|
|||||||
struct avl_node node;
|
struct avl_node node;
|
||||||
uint8_t macaddr[ETH_ALEN];
|
uint8_t macaddr[ETH_ALEN];
|
||||||
uint32_t arp_ip4addr;
|
uint32_t arp_ip4addr;
|
||||||
|
bool arp;
|
||||||
uint32_t ip4addr;
|
uint32_t ip4addr;
|
||||||
uint32_t ip6addr[4];
|
uint32_t ip6addr[4];
|
||||||
uint32_t time;
|
uint32_t time;
|
||||||
@@ -214,16 +215,19 @@ out:
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_set_ipaddr(const void *mac, const void *addr, bool ipv6)
|
void client_set_ipaddr(const void *mac, const void *addr, bool ipv6, bool arp)
|
||||||
{
|
{
|
||||||
struct interface *iface;
|
struct interface *iface;
|
||||||
struct cache_entry *c;
|
struct cache_entry *c;
|
||||||
struct client *cl;
|
struct client *cl;
|
||||||
|
|
||||||
c = client_get_cache_entry(mac);
|
c = client_get_cache_entry(mac);
|
||||||
if (!ipv6 && !c->ip4addr)
|
if (!ipv6 && arp && c->arp)
|
||||||
|
return;
|
||||||
|
if (!ipv6 && (!c->ip4addr || c->arp)) {
|
||||||
memcpy(&c->ip4addr, addr, sizeof(c->ip4addr));
|
memcpy(&c->ip4addr, addr, sizeof(c->ip4addr));
|
||||||
else if (ipv6 && !c->ip6addr[0])
|
c->arp = arp;
|
||||||
|
} else if (ipv6 && !c->ip6addr[0])
|
||||||
memcpy(&c->ip6addr, addr, sizeof(c->ip6addr));
|
memcpy(&c->ip6addr, addr, sizeof(c->ip6addr));
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ int client_set(struct interface *iface, const void *addr, const char *id,
|
|||||||
int state, int dns_state, int accounting, struct blob_attr *data,
|
int state, int dns_state, int accounting, struct blob_attr *data,
|
||||||
const char *device, bool flush);
|
const char *device, bool flush);
|
||||||
void client_free(struct interface *iface, struct client *cl);
|
void client_free(struct interface *iface, struct client *cl);
|
||||||
void client_set_ipaddr(const void *mac, const void *addr, bool ipv6);
|
void client_set_ipaddr(const void *mac, const void *addr, bool ipv6, bool arp);
|
||||||
void client_set_arp_ipaddr(const void *mac, const void *addr);
|
void client_set_arp_ipaddr(const void *mac, const void *addr);
|
||||||
void client_init_interface(struct interface *iface);
|
void client_init_interface(struct interface *iface);
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,6 @@ void spotfilter_recv_dhcpv4(const void *msgdata, int len, const void *eth_addr)
|
|||||||
if (op != DHCPV4_MSG_ACK)
|
if (op != DHCPV4_MSG_ACK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client_set_ipaddr(msg->chaddr, (uint32_t *)&msg->yiaddr, false);
|
client_set_ipaddr(msg->chaddr, (uint32_t *)&msg->yiaddr, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,5 +42,5 @@ void spotfilter_recv_icmpv6(const void *data, int len, const uint8_t *src, const
|
|||||||
if (opt != (const struct icmpv6_opt *)(data + len))
|
if (opt != (const struct icmpv6_opt *)(data + len))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client_set_ipaddr(src, &nd->nd_na_target, true);
|
client_set_ipaddr(src, &nd->nd_na_target, true, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -441,6 +441,7 @@ spotfilter_packet_cb(struct packet *pkt)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
client_set_arp_ipaddr(eth->h_source, &arp->src_ip);
|
client_set_arp_ipaddr(eth->h_source, &arp->src_ip);
|
||||||
|
client_set_ipaddr(eth->h_source, &arp->src_ip, false, true);
|
||||||
break;
|
break;
|
||||||
case ETH_P_IP:
|
case ETH_P_IP:
|
||||||
ip = pkt_peek(pkt, sizeof(struct ip));
|
ip = pkt_peek(pkt, sizeof(struct ip));
|
||||||
|
|||||||
Reference in New Issue
Block a user