From 83853178bd36bca6f0f8f1331476620c84a587fc Mon Sep 17 00:00:00 2001 From: Ed Swarthout Date: Wed, 7 Mar 2007 12:14:50 -0600 Subject: 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 Signed-off-by: Ben Warren --- net/net.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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; -- cgit v1.1 From 443feb740584e406efa203af909fe2926608e8d5 Mon Sep 17 00:00:00 2001 From: Igor Marnat Date: Wed, 21 Mar 2007 09:55:01 +0300 Subject: Update usage of 'nc' in README.NetConsole Added information about usage of NetConsole on systems where the -l and -p switches are mutually exclusive. Signed-off-by: Igor Marnat Signed-off-by: Ben Warren --- doc/README.NetConsole | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/README.NetConsole b/doc/README.NetConsole index cc35a0a..fea8e33 100644 --- a/doc/README.NetConsole +++ b/doc/README.NetConsole @@ -38,6 +38,11 @@ The script expects exactly one argument, which is interpreted as the target IP address (or host name, assuming DNS is working). The script can be interrupted by pressing ^T (CTRL-T). +Be aware that in some distributives (Fedora Core 5 at least) +usage of nc has been changed and -l and -p options are considered +as mutually exclusive. If nc complains about options provided, +you can just remove the -p option from the script. + It turns out that 'netcat' cannot be used to listen to broadcast packets. We developed our own tool 'ncb' (see tools directory) that listens to broadcast packets on a given port and dumps them to the -- cgit v1.1