]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: Add an accessor to know if waiting for ARP
authorJoe Hershberger <joe.hershberger@ni.com>
Wed, 26 Sep 2018 21:48:58 +0000 (16:48 -0500)
committerJoe Hershberger <joe.hershberger@ni.com>
Wed, 10 Oct 2018 17:28:58 +0000 (12:28 -0500)
This single-sources the state of the ARP.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
include/net.h
net/arp.c

index 156bdc1da4d4afe83a4190406af2379d68dba26a..40e895316eea0b40b134de1dd7a2c28a593dafc7 100644 (file)
@@ -636,6 +636,7 @@ rxhand_f *net_get_udp_handler(void);        /* Get UDP RX packet handler */
 void net_set_udp_handler(rxhand_f *);  /* Set UDP RX packet handler */
 rxhand_f *net_get_arp_handler(void);   /* Get ARP RX packet handler */
 void net_set_arp_handler(rxhand_f *);  /* Set ARP RX packet handler */
+bool arp_is_waiting(void);             /* Waiting for ARP reply? */
 void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */
 void net_set_timeout_handler(ulong, thand_f *);/* Set timeout handler */
 
index b8a71684cd768c36b30d38393482d9ebd4aca536..ea685d9ac6ec1fa9afc215b067bc2237b3da4c10 100644 (file)
--- a/net/arp.c
+++ b/net/arp.c
@@ -100,7 +100,7 @@ int arp_timeout_check(void)
 {
        ulong t;
 
-       if (!net_arp_wait_packet_ip.s_addr)
+       if (!arp_is_waiting())
                return 0;
 
        t = get_timer(0);
@@ -187,8 +187,8 @@ void arp_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
                return;
 
        case ARPOP_REPLY:               /* arp reply */
-               /* are we waiting for a reply */
-               if (!net_arp_wait_packet_ip.s_addr)
+               /* are we waiting for a reply? */
+               if (!arp_is_waiting())
                        break;
 
 #ifdef CONFIG_KEEP_SERVERADDR
@@ -233,3 +233,8 @@ void arp_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
                return;
        }
 }
+
+bool arp_is_waiting(void)
+{
+       return !!net_arp_wait_packet_ip.s_addr;
+}