net/arp: add link layer check for arp_out/arp_ipin

ARP support is only built if the Ethernet link layer is supported.
Continue and send the ARP request only if this device uses the
Ethernet link layer protocol.

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2022-11-27 03:11:22 +08:00 committed by Xiang Xiao
parent 8850dee746
commit 81325a8a3d
2 changed files with 22 additions and 0 deletions

View File

@ -76,6 +76,17 @@ void arp_ipin(FAR struct net_driver_s *dev)
{
in_addr_t srcipaddr;
/* ARP support is only built if the Ethernet link layer is supported.
* Continue and send the ARP request only if this device uses the
* Ethernet link layer protocol.
*/
if (dev->d_lltype != NET_LL_ETHERNET &&
dev->d_lltype != NET_LL_IEEE80211)
{
return;
}
/* Only insert/update an entry if the source IP address of the incoming IP
* packet comes from a host on the local network.
*/

View File

@ -137,6 +137,17 @@ void arp_out(FAR struct net_driver_s *dev)
in_addr_t destipaddr;
int ret;
/* ARP support is only built if the Ethernet link layer is supported.
* Continue and send the ARP request only if this device uses the
* Ethernet link layer protocol.
*/
if (dev->d_lltype != NET_LL_ETHERNET &&
dev->d_lltype != NET_LL_IEEE80211)
{
return;
}
#if defined(CONFIG_NET_PKT) || defined(CONFIG_NET_ARP_SEND)
/* Skip sending ARP requests when the frame to be transmitted was
* written into a packet socket.