summaryrefslogtreecommitdiff
path: root/nuttx/net/icmp/icmp_ping.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-08-18 16:22:14 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-08-18 16:22:14 -0600
commit4f670b87fdecc7e9314f8bac0717e8961f9151bf (patch)
tree25ea58943bc0a26b0efed11ef97eaab1b3d1845e /nuttx/net/icmp/icmp_ping.c
parentd0b89b78f0cce276ed9bee65cb640787080d6062 (diff)
downloadnuttx-4f670b87fdecc7e9314f8bac0717e8961f9151bf.tar.gz
nuttx-4f670b87fdecc7e9314f8bac0717e8961f9151bf.tar.bz2
nuttx-4f670b87fdecc7e9314f8bac0717e8961f9151bf.zip
If CONFIG_NET_ARP_SEND is enabled, then all ICMP, TCP, and UDP send operations will call arp_send() before attempting the real send operation. arp_send() will check if the the IP address mapping is in the ARP table and, if not send ARP requests periodically until it is. This eliminates losing the first outgoing message because there is not mapping in the ARP table.
Diffstat (limited to 'nuttx/net/icmp/icmp_ping.c')
-rw-r--r--nuttx/net/icmp/icmp_ping.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/nuttx/net/icmp/icmp_ping.c b/nuttx/net/icmp/icmp_ping.c
index 53838b47e..3cd900b94 100644
--- a/nuttx/net/icmp/icmp_ping.c
+++ b/nuttx/net/icmp/icmp_ping.c
@@ -58,6 +58,7 @@
#include "netdev/netdev.h"
#include "devif/devif.h"
+#include "arp/arp.h"
#include "icmp/icmp.h"
/****************************************************************************
@@ -331,6 +332,18 @@ int icmp_ping(net_ipaddr_t addr, uint16_t id, uint16_t seqno,
{
struct icmp_ping_s state;
net_lock_t save;
+#ifdef CONFIG_NET_ARP_SEND
+ int ret;
+
+ /* Make sure that the IP address mapping is in the ARP table */
+
+ ret = arp_send(addr);
+ if (ret < 0)
+ {
+ ndbg("ERROR: Not reachable\n");
+ return -ENETUNREACH;
+ }
+#endif
/* Initialize the state structure */