All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ed Swarthout <Ed.Swarthout@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] net - Support ping reply when processing net-loop
Date: Wed,  7 Mar 2007 12:14:50 -0600	[thread overview]
Message-ID: <1173291290423-git-send-email-Ed.Swarthout@freescale.com> (raw)
In-Reply-To: <1173279099.24846.135.camel@saruman.qstreams.net>

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>

---

Version 3.  Whitespace cleanup of patch.

Removed spaces used for indentation of descendant line.
80-char line-length is still violated (like other parts of file).

If I run Lident on the file, I get 67 changes and it still uses spaces
to indent descendant lines.  Should I send that version instead?

Pain leads to strength...

 net/net.c |   20 ++++++++++++++++++++
 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;
-- 
1.5.0.2.279.g4808

  parent reply	other threads:[~2007-03-07 18:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-06  5:33 [U-Boot-Users] [PATCH] net - Support ping reply when processing net-loop Ed Swarthout
2007-03-06 15:56 ` Ben Warren
2007-03-06 17:59   ` [U-Boot-Users] HUSH shell in u-boot Leonid
2007-03-06 21:40     ` Wolfgang Denk
2007-03-07 10:07       ` [U-Boot-Users] HUSH shell in u-boot.- CONFIG_CMDLINE_EDITING Sam Song
2007-03-08  4:55         ` Swarthout Edward L-SWARTHOU
2007-03-08 14:44           ` Sam Song
2007-03-07  6:12   ` [U-Boot-Users] [PATCH] net - Support ping reply when processing net-loop Ed Swarthout
2007-03-07 14:51     ` Ben Warren
2007-03-07 15:09       ` Wolfgang Denk
2007-03-07 18:14       ` Ed Swarthout [this message]
2007-03-07 18:31         ` Ben Warren
  -- strict thread matches above, loose matches on Subject: below --
2007-03-06  7:20 Ed Swarthout

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1173291290423-git-send-email-Ed.Swarthout@freescale.com \
    --to=ed.swarthout@freescale.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.