summaryrefslogtreecommitdiff
path: root/nuttx/net/uip/uip-icmpping.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-09-02 23:04:10 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-09-02 23:04:10 +0000
commit9f60d09c6faaac732a62a188228a88321aad7368 (patch)
tree4404ee0e25d63abaad5e23b9aa8dce9ed6a9c8e9 /nuttx/net/uip/uip-icmpping.c
parent8a2d54981a1c1ee6563f3444cffc1d2d4784156e (diff)
downloadpx4-nuttx-9f60d09c6faaac732a62a188228a88321aad7368.tar.gz
px4-nuttx-9f60d09c6faaac732a62a188228a88321aad7368.tar.bz2
px4-nuttx-9f60d09c6faaac732a62a188228a88321aad7368.zip
Add NSH ping command
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@870 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/uip/uip-icmpping.c')
-rw-r--r--nuttx/net/uip/uip-icmpping.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/nuttx/net/uip/uip-icmpping.c b/nuttx/net/uip/uip-icmpping.c
index e62209dcd..5bc9b68b0 100644
--- a/nuttx/net/uip/uip-icmpping.c
+++ b/nuttx/net/uip/uip-icmpping.c
@@ -58,6 +58,7 @@
****************************************************************************/
#define ICMPBUF ((struct uip_icmpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
+#define ICMPDAT &dev->d_buf[UIP_LLH_LEN + sizeof(struct uip_icmpip_hdr)]
/* Allocate a new ICMP data callback */
@@ -79,6 +80,7 @@ struct icmp_ping_s
uip_ipaddr_t png_addr; /* The peer to be ping'ed */
uint16 png_id; /* Used to match requests with replies */
uint16 png_seqno; /* IN: seqno to send; OUT: seqno recieved */
+ uint16 png_datlen; /* The length of data to send in the ECHO request */
boolean png_sent; /* TRUE... the PING request has been sent */
};
@@ -211,13 +213,14 @@ static uint16 ping_interrupt(struct uip_driver_s *dev, void *conn,
#else
# error "IPv6 ECHO Request not implemented"
#endif
+ memset(ICMPDAT, 0, pstate->png_datlen);
/* Send the ICMP echo request. Note that d_sndlen is set to
* the size of the ICMP payload and does not include the size
* of the ICMP header.
*/
- dev->d_sndlen= 4;
+ dev->d_sndlen= pstate->png_datlen + 4;
uip_icmpsend(dev, &pstate->png_addr);
pstate->png_sent = TRUE;
return flags;
@@ -283,7 +286,7 @@ end_wait:
*
****************************************************************************/
-int uip_ping(uip_ipaddr_t addr, uint16 id, uint16 seqno, int dsecs)
+int uip_ping(uip_ipaddr_t addr, uint16 id, uint16 seqno, uint16 datalen, int dsecs)
{
struct icmp_ping_s state;
irqstate_t save;
@@ -296,6 +299,7 @@ int uip_ping(uip_ipaddr_t addr, uint16 id, uint16 seqno, int dsecs)
state.png_addr = addr; /* Address of the peer to be ping'ed */
state.png_id = id; /* The ID to use in the ECHO request */
state.png_seqno = seqno; /* The seqno to use int the ECHO request */
+ state.png_datlen = datalen; /* The length of data to send in the ECHO request */
state.png_sent = FALSE; /* ECHO request not yet sent */
save = irqsave();
@@ -303,7 +307,7 @@ int uip_ping(uip_ipaddr_t addr, uint16 id, uint16 seqno, int dsecs)
/* Set up the callback */
- state.png_cb = uip_icmpcallbackalloc();
+ state.png_cb = uip_icmpcallbackalloc();
if (state.png_cb)
{
state.png_cb->flags = UIP_POLL|UIP_ECHOREPLY;