From 81325a8a3d45fedcc03dce97c88ff99945ba9f7f Mon Sep 17 00:00:00 2001 From: chao an Date: Sun, 27 Nov 2022 03:11:22 +0800 Subject: [PATCH] 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 --- net/arp/arp_ipin.c | 11 +++++++++++ net/arp/arp_out.c | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/net/arp/arp_ipin.c b/net/arp/arp_ipin.c index 893f80327a..8803301e28 100644 --- a/net/arp/arp_ipin.c +++ b/net/arp/arp_ipin.c @@ -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. */ diff --git a/net/arp/arp_out.c b/net/arp/arp_out.c index a6dba47420..cf4b57b465 100644 --- a/net/arp/arp_out.c +++ b/net/arp/arp_out.c @@ -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.