summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorEd Swarthout <Ed.Swarthout@freescale.com>2007-03-07 12:14:50 -0600
committerBen Warren <bwarren@qstreams.com>2007-03-07 18:12:15 -0500
commit83853178bd36bca6f0f8f1331476620c84a587fc (patch)
treee5408afbc6f933e6da2c16a1ab119b7864fc026c /net
parentccbc7036648e465697ca298ba51e0e76dda352a0 (diff)
downloadu-boot-imx-83853178bd36bca6f0f8f1331476620c84a587fc.zip
u-boot-imx-83853178bd36bca6f0f8f1331476620c84a587fc.tar.gz
u-boot-imx-83853178bd36bca6f0f8f1331476620c84a587fc.tar.bz2
net - Support ping reply when processing net-loop
Add ICMP_ECHO_REQUEST packet support by responding with a ICMP_ECHO_REPLY. This permits the ping command to test the phy interface when the phy is put in loopback mode (typically by setting register 0 bit 14). It also allows the port to respond to an external ping when u-boot is processing some other net command (such as tftp). This is useful when tftp appears to hang. Signed-off-by: Ed Swarthout <Ed.Swarthout@freescale.com> Signed-off-by: Ben Warren <bwarren@qstreams.com>
Diffstat (limited to 'net')
-rw-r--r--net/net.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/net.c b/net/net.c
index 1d1c98f..2ff7bfc 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1424,6 +1424,26 @@ NetReceive(volatile uchar * inpkt, int len)
/* XXX point to ip packet */
(*packetHandler)((uchar *)ip, 0, 0, 0);
return;
+ case ICMP_ECHO_REQUEST:
+#ifdef ET_DEBUG
+ printf ("Got ICMP ECHO REQUEST, return %d bytes \n",
+ ETHER_HDR_SIZE + len);
+#endif
+ memcpy (&et->et_dest[0], &et->et_src[0], 6);
+ memcpy (&et->et_src[ 0], NetOurEther, 6);
+
+ ip->ip_sum = 0;
+ ip->ip_off = 0;
+ NetCopyIP((void*)&ip->ip_dst, &ip->ip_src);
+ NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP >> 1);
+
+ icmph->type = ICMP_ECHO_REPLY;
+ icmph->checksum = 0;
+ icmph->checksum = ~NetCksum((uchar *)icmph,
+ (len - IP_HDR_SIZE_NO_UDP) >> 1);
+ (void) eth_send((uchar *)et, ETHER_HDR_SIZE + len);
+ return;
#endif
default:
return;