From: wdenk Date: Thu, 11 Jan 2001 22:40:50 +0000 (+0000) Subject: Modifications for 0.7.2: X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e0767d7b39059daf08ad0b76a21331d841c522db;p=users%2Frw%2Fppcboot.git Modifications for 0.7.2: * New configuration for RDS prototype board (by Marius Gröger) * New i2c.c driver for 82xx (by Marius Gröger) * Fix TFTP over routers: send ARP to router's ethernet address. * Add code to recognize ICMP Host Redirect messages; print a warning (probably bad BOOTP server configuration, like announcing a wrong or unnecessary router). * Fix BCSR address in FADS860T configuration (preventing ethernet from working) * "setenv" and "saveenv" commands no longer auto-repeatable * Restrict baudrate settings to certain legal values (see table CFG_BAUDRATE_TABLE in the board's config header file) * Now baudrate changes take place immediately (without reset) ---------------------------------------------------------------------- GENIETV patch by Paolo Scaffardi (Fri, 5 Jan 2001 11:27:44 +0100): * Added support for AMDLV040B 512Kb flash into flash.h * Changed TEXTBASE into GENIETV configuration * Added VIDEO_ADDR definition into config_GENIETV.h * Removed unused files: wl_4ppm_keyboard.c and wl_4ppm_keyboard.h ---------------------------------------------------------------------- * Fix in cpu/mpc8xx/fec.c (by Dave Ellis): The PHY discovery code must be called after the FEC is enabled, since it uses the FEC to talk to the PHY. * Fix bug in clock routing when using SMC2 for console. * EEPROM Speedup; allow other addresses (by Dave Ellis) * Added SXNI855T configuration (by Dave Ellis) --- diff --git a/CHANGELOG b/CHANGELOG index 769bcdc..36cf735 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -65,6 +65,15 @@ Modifications for 0.7.2: * New i2c.c driver for 82xx (by Marius Gröger) +* Fix TFTP over routers: send ARP to router's ethernet address. + +* Add code to recognize ICMP Host Redirect messages; print a warning + (probably bad BOOTP server configuration, like announcing a wrong + or unnecessary router). + +* Fix BCSR address in FADS860T configuration (preventing ethernet + from working) + * "setenv" and "saveenv" commands no longer auto-repeatable * Restrict baudrate settings to certain legal values (see table diff --git a/board/rsdproto/Makefile b/board/rsdproto/Makefile index e8f5a5c..9934787 100644 --- a/board/rsdproto/Makefile +++ b/board/rsdproto/Makefile @@ -26,9 +26,9 @@ include $(TOPDIR)/config.mk LIB = lib$(BOARD).a OBJS := rsdproto.o flash.o -SOBJS := +SOBJS := flash_asm.o -$(LIB): $(OBJS) +$(LIB): $(OBJS) $(SOBJS) $(AR) crv $@ $^ clean: diff --git a/board/rsdproto/flash.c b/board/rsdproto/flash.c index e0c5ee8..5b66186 100644 --- a/board/rsdproto/flash.c +++ b/board/rsdproto/flash.c @@ -67,66 +67,19 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */ * Functions */ -static unsigned char write_ull(flash_info_t *info, unsigned long address, - volatile unsigned long long data); static int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt); int flash_write(uchar *, ulong, ulong); flash_info_t *addr2info (ulong); - static int flash_protect (int flag, ulong from, ulong to, flash_info_t *info); +static unsigned char write_ull(flash_info_t *info, + unsigned long address, + volatile unsigned long long data); -/*--------------------------------------------------------------------------- -* -* MACRO NAME: ull_read/ull_write -* -* DESCRIPTION: uses the floating point unit from 8260 to read and write -* 64 bit wide data (unsigned long long) on the 60x bus. -* this is necessary because all 4 Flash Chips use the /WE line -* from byte lane 0 -* important -> data should allways be 8-alligned, otherwise exception !! -* -* EXTERNAL EFFECT: scratch register f0 -* -* PARAMETERS: 32 bit long pointer to adress, 64 bit long pointer to data -* -* RETURNS: nothing -*--------------------------------------------------------------------------*/ - -static void ull_write(unsigned long long volatile *address, - unsigned long long volatile *data) -{ - double tmp; - - __asm__ __volatile__( - " lfd %0,0(%2)\n" - " stfd %1,0(%3)\n" - : "=f" (tmp) /* outputs */ - : "0" (tmp), "r" (data), "r" (address) /* inputs */ - ); - - D(("ull_write: address %08lx <- data %08lx%08lx\n", - (ulong)address, - (ulong)(*data >> 32), (ulong)(*data & 0xffffffff))); -} - -#ifdef WITH_AUTOSELECT -static void ull_read(unsigned long long *address, - unsigned long long *data) -{ - double tmp; - - __asm__ __volatile__( - " lfd %0,0(%3)\n" - " stfd %1,0(%2)\n" - : "=f" (tmp) /* outputs */ - : "0" (tmp), "r" (data), "r" (address) /* inputs */ - ); - - D(("ull_read: address %08lx -> data %08lx%08lx\n", - (ulong)address, - (ulong)(*data >> 32), (ulong)(*data & 0xffffffff))); -} -#endif +/* from flash_asm.S */ +extern void ull_write(unsigned long long volatile *address, + unsigned long long volatile *data); +extern void ull_read(unsigned long long volatile *address, + unsigned long long volatile *data); /*----------------------------------------------------------------------- */ @@ -138,7 +91,7 @@ unsigned long flash_init (void) #ifdef WITH_AUTOSELECT { - unsigned long long *f_addr = (unsigned long long *)CFG_FLASH_BASE; + unsigned long long *f_addr = (unsigned long long *)PHYS_FLASH; unsigned long long f_command, vendor, device; /* Perform Autoselect */ f_command = 0x00AA00AA00AA00AAULL; @@ -167,7 +120,7 @@ unsigned long flash_init (void) flash_info[0].flash_id = VENDOR_AMD << 16 | AMD_29DL323C_B; flash_info[0].sector_count = 8; flash_info[0].size = flash_info[0].sector_count * 32 * 1024; - addr = CFG_FLASH_BASE; + addr = PHYS_FLASH; for(i = 0; i < flash_info[0].sector_count; i++) { flash_info[0].start[i] = addr; addr += flash_info[0].size / flash_info[0].sector_count; @@ -185,22 +138,29 @@ unsigned long flash_init (void) * protect monitor and environment sectors */ -#if CFG_MONITOR_BASE >= CFG_FLASH_BASE +#if CFG_MONITOR_BASE >= PHYS_FLASH (void)flash_protect(FLAG_PROTECT_SET, CFG_MONITOR_BASE, CFG_MONITOR_BASE+CFG_MONITOR_LEN-1, &flash_info[0]); + (void)flash_protect(FLAG_PROTECT_SET, + CFG_MONITOR_BASE, + CFG_MONITOR_BASE+CFG_MONITOR_LEN-1, + &flash_info[1]); #endif -#if defined(CFG_FLASH_ENV_ADDR) +#if (CFG_ENV_IS_IN_FLASH == 1) && defined(CFG_ENV_ADDR) +# ifndef CFG_ENV_SIZE +# define CFG_ENV_SIZE CFG_ENV_SECT_SIZE +# endif (void)flash_protect(FLAG_PROTECT_SET, - CFG_FLASH_ENV_ADDR, -#if defined(CFG_FLASH_ENV_BUF) - CFG_FLASH_ENV_ADDR + CFG_FLASH_ENV_BUF - 1, -#else - CFG_FLASH_ENV_ADDR + CFG_ENV_SIZE - 1, -#endif - &flash_info[0]); + CFG_ENV_ADDR, + CFG_ENV_ADDR + CFG_ENV_SIZE - 1, + &flash_info[0]); + (void)flash_protect(FLAG_PROTECT_SET, + CFG_ENV_ADDR, + CFG_ENV_ADDR + CFG_ENV_SIZE - 1, + &flash_info[1]); #endif return flash_info[0].size + flash_info[1].size; diff --git a/board/rsdproto/flash_asm.S b/board/rsdproto/flash_asm.S new file mode 100644 index 0000000..7368c5a --- /dev/null +++ b/board/rsdproto/flash_asm.S @@ -0,0 +1,39 @@ +/* + * -*- mode:c -*- + * + * (C) Copyright 2000 + * Marius Groeger + * Sysgo Real-Time Solutions, GmbH + * + * void ull_write(unsigned long long volatile *address, + * unsigned long long volatile *data) + * r3 = address + * r4 = data + * + * void ull_read(unsigned long long volatile *address, + * unsigned long long volatile *data) + * r3 = address + * r4 = data + * + * Uses the floating point unit to read and write 64 bit wide + * data (unsigned long long) on the 60x bus. This is necessary + * because all 4 flash chips use the /WE line from byte lane 0 + * + * IMPORTANT: data should always be 8-aligned, otherwise an exception will + * occur. + */ + +#include +#include + +.globl ull_write +ull_write: + lfd 0,0(r4) + stfd 0,0(r3) + blr + + .globl ull_read +ull_read: + lfd 0, 0(r3) + stfd 0, 0(r4) + blr diff --git a/board/rsdproto/ppcboot.lds b/board/rsdproto/ppcboot.lds index 596a2c5..af67e21 100644 --- a/board/rsdproto/ppcboot.lds +++ b/board/rsdproto/ppcboot.lds @@ -54,15 +54,10 @@ SECTIONS .text : { cpu/mpc8260/start.o (.text) - common/dlmalloc.o (.text) - ppc/ppcstring.o (.text) - ppc/vsprintf.o (.text) - ppc/crc32.o (.text) - . = env_offset; - common/environment.o(.text) *(.text) *(.fixup) *(.got1) + /*. = env_offset; */ } _etext = .; PROVIDE (etext = .); diff --git a/common/board.c b/common/board.c index 68c635e..79ec74e 100644 --- a/common/board.c +++ b/common/board.c @@ -195,7 +195,7 @@ board_init_f (ulong bootflag) hang(); } -#if defined(CONFIG_COGENT) || defined(CONFIG_SXNI855T) +#if defined(CONFIG_COGENT) || defined(CONFIG_SXNI855T) || defined(CONFIG_RSD_PROTO) /* miscellaneous platform dependent initialisations */ if (misc_init_f() < 0) { printf (failed); diff --git a/common/main.c b/common/main.c index b4f0383..192e16d 100644 --- a/common/main.c +++ b/common/main.c @@ -474,7 +474,7 @@ static void run_command (int len, } #ifdef DEBUG_PARSER -printf ("[RUN_COMMAND] lastlen=%d -> %s\n", lastlen, lastcommand); + printf ("[RUN_COMMAND] lastlen=%d -> %s\n", lastlen, lastcommand); #endif /* Process separators and check for non-valid repeatable commands */ if (process_separators (lastcommand, lastlen, cmdtp, bd, flag) == 0) { diff --git a/cpu/mpc8xx/scc.c b/cpu/mpc8xx/scc.c index 93f0e15..ceab3de 100644 --- a/cpu/mpc8xx/scc.c +++ b/cpu/mpc8xx/scc.c @@ -117,8 +117,7 @@ int eth_rx(void) { int length; - for (;;) - { + for (;;) { /* section 16.9.23.2 */ if (rtx->rxbd[rxIdx].cbd_sc & BD_ENET_RX_EMPTY) { length = -1; @@ -127,14 +126,11 @@ int eth_rx(void) length = rtx->rxbd[rxIdx].cbd_datlen; - if (rtx->rxbd[rxIdx].cbd_sc & 0x003f) - { + if (rtx->rxbd[rxIdx].cbd_sc & 0x003f) { #ifdef ET_DEBUG printf("err: %x\n", rtx->rxbd[rxIdx].cbd_sc); #endif - } - else - { + } else { /* Pass the packet up to the protocol layers. */ NetReceive(NetRxPackets[rxIdx], length - 4); } @@ -147,8 +143,7 @@ int eth_rx(void) if ((rxIdx + 1) >= PKTBUFSRX) { rtx->rxbd[PKTBUFSRX - 1].cbd_sc = (BD_ENET_RX_WRAP | BD_ENET_RX_EMPTY); rxIdx = 0; - } - else { + } else { rtx->rxbd[rxIdx].cbd_sc = BD_ENET_RX_EMPTY; rxIdx++; } diff --git a/include/config_FADS860T.h b/include/config_FADS860T.h index b786148..048b812 100644 --- a/include/config_FADS860T.h +++ b/include/config_FADS860T.h @@ -245,7 +245,7 @@ */ /* the other CS:s are determined by looking at parameters in BCSRx */ -#define BCSR_ADDR ((uint) 0xFF01000) +#define BCSR_ADDR ((uint) 0xFF010000) #define BCSR_SIZE ((uint)(64 * 1024)) #define FLASH_BASE0_PRELIM 0x2800000 /* FLASH bank #0 */ diff --git a/include/config_rsdproto.h b/include/config_rsdproto.h index 6ba21e0..67f1bcf 100644 --- a/include/config_rsdproto.h +++ b/include/config_rsdproto.h @@ -82,13 +82,13 @@ /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ #include -#if 0 +#if 1 #define CONFIG_BOOTDELAY -1 /* autoboot disabled */ #else -#define CONFIG_BOOTDELAY 25 /* autoboot after 5 seconds */ +#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */ #endif //#define CONFIG_BOOTCOMMAND "bootm 04080000 04200000" /* autoboot command*/ -#define CONFIG_BOOTCOMMAND "bootp" +#define CONFIG_BOOTCOMMAND "" #define CONFIG_BOOTARGS \ "root=/dev/nfs rw " \ @@ -102,30 +102,32 @@ #define CONFIG_KGDB_SER_INDEX 2 /* which serial port to use */ #endif -#undef CONFIG_WATCHDOG /* turn on platform specific watchdog */ +#undef CONFIG_WATCHDOG /* turn on platform specific watchdog */ /* * Miscellaneous configurable options */ -#define CFG_LONGHELP /* undef to save memory */ -#define CFG_PROMPT "=> " /* Monitor Command Prompt */ +#define CFG_LONGHELP /* undef to save memory */ +#define CFG_PROMPT "=> " /* Monitor Command Prompt */ #if (CONFIG_COMMANDS & CFG_CMD_KGDB) -#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */ +#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */ #else -#define CFG_CBSIZE 256 /* Console I/O Buffer Size */ +#define CFG_CBSIZE 256 /* Console I/O Buffer Size */ #endif #define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */ -#define CFG_MAXARGS 16 /* max number of command args */ +#define CFG_MAXARGS 16 /* max number of command args */ #define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */ #define CFG_MEMTEST_START 0x00400000 /* memtest works on */ #define CFG_MEMTEST_END 0x01c00000 /* 4 ... 28 MB in DRAM */ -#undef CFG_CLKS_IN_HZ /* everything, incl board info, in Hz */ +#undef CFG_CLKS_IN_HZ /* everything, incl board info, in Hz */ #define CFG_LOAD_ADDR 0x100000 /* default load address */ -#define CFG_HZ 1000 /* decrementer freq: 1 ms ticks */ +#define CFG_HZ 1000 /* decrementer freq: 1 ms ticks */ + +#define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 } /* * Low Level Configuration Settings @@ -136,16 +138,16 @@ /*----------------------------------------------------------------------- * Physical Memory Map */ -#define PHYS_SDRAM_60X 0x00000000 /* SDRAM (60x Bus) */ -#define PHYS_SDRAM_60X_SIZE 0x08000000 /* 128 MB */ +#define PHYS_SDRAM_60X 0x00000000 /* SDRAM (60x Bus) */ +#define PHYS_SDRAM_60X_SIZE 0x08000000 /* 128 MB */ -#define PHYS_SDRAM_LOCAL 0x40000000 /* SDRAM (Local Bus) */ +#define PHYS_SDRAM_LOCAL 0x40000000 /* SDRAM (Local Bus) */ #define PHYS_SDRAM_LOCAL_SIZE 0x04000000 /* 64 MB */ #define PHYS_DPRAM_PCI 0x04000000 /* DPRAM PPC/PCI */ #define PHYS_DPRAM_PCI_SIZE 0x00020000 /* 128 KB */ -#define PHYS_DPRAM_PCI_SEM 0x04020000 /* DPRAM PPC/PCI Semaphore */ +#define PHYS_DPRAM_PCI_SEM 0x04020000 /* DPRAM PPC/PCI Semaphore */ #define PHYS_DPRAM_PCI_SEM_SIZE 0x00000001 /* 1 Byte */ #define PHYS_DPRAM_SHARC 0x04100000 /* DPRAM PPC/Sharc */ @@ -154,15 +156,15 @@ #define PHYS_DPRAM_SHARC_SEM 0x04140000 /* DPRAM PPC/Sharc Semaphore */ #define PHYS_DPRAM_SHARC_SEM_SIZE 0x00000001 /* 1 Byte */ -#define PHYS_USB 0x04200000 /* USB Controller (60x Bus) */ -#define PHYS_USB_SIZE 0x00000002 /* 2 Bytes */ +#define PHYS_USB 0x04200000 /* USB Controller (60x Bus) */ +#define PHYS_USB_SIZE 0x00000002 /* 2 Bytes */ -#define PHYS_IMMR 0xF0000000 /* Internal Memory Mapped Reg. */ +#define PHYS_IMMR 0xF0000000 /* Internal Memory Mapped Reg. */ -#define PHYS_FLASH 0xFF000000 /* Flash (60x Bus) */ -#define PHYS_FLASH_SIZE 0x01000000 /* 16 MB */ +#define PHYS_FLASH 0xFF000000 /* Flash (60x Bus) */ +#define PHYS_FLASH_SIZE 0x01000000 /* 16 MB */ -#define CFG_IMMR PHYS_IMMR +#define CFG_IMMR PHYS_IMMR /* turn off NVRAM env feature */ #undef CONFIG_NVRAM_ENV @@ -202,9 +204,9 @@ * Please note that CFG_SDRAM_BASE _must_ start at 0 */ #define CFG_SDRAM_BASE PHYS_SDRAM_60X -#define CFG_FLASH_BASE PHYS_FLASH -#define CFG_MONITOR_BASE 0x200000 -//#define CFG_MONITOR_BASE 0xfff00000 +#define CFG_FLASH_BASE 0xFFF00000 +//#define CFG_MONITOR_BASE 0x200000 +#define CFG_MONITOR_BASE 0xfff00000 #define CFG_MONITOR_LEN (256 << 10) /* Reserve 256 kB for Monitor */ #define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */ @@ -218,15 +220,15 @@ /*----------------------------------------------------------------------- * FLASH organization */ -#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */ -#define CFG_MAX_FLASH_SECT 63 /* max number of sectors on one chip */ +#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */ +#define CFG_MAX_FLASH_SECT 63 /* max number of sectors on one chip */ -#define CFG_FLASH_ERASE_TOUT 12000 /* Timeout for Flash Erase (in ms) */ -#define CFG_FLASH_WRITE_TOUT 3000 /* Timeout for Flash Write (in ms) */ +#define CFG_FLASH_ERASE_TOUT 12000 /* Timeout for Flash Erase (in ms) */ +#define CFG_FLASH_WRITE_TOUT 3000 /* Timeout for Flash Write (in ms) */ #define CFG_ENV_IS_IN_FLASH 1 -#define CFG_ENV_OFFSET 0x8000 /* Addr of Environment Sector */ -#define CFG_ENV_SIZE 0x8000 /* Total Size of Environment Sector */ +#define CFG_ENV_ADDR (PHYS_FLASH + 0x8000) /* Addr of Environment Sector */ +#define CFG_ENV_SECT_SIZE 0x8000 /* Total Size of Environment Sector */ /*----------------------------------------------------------------------- * Cache Configuration diff --git a/include/net.h b/include/net.h index 5243aaa..6faab6b 100644 --- a/include/net.h +++ b/include/net.h @@ -85,6 +85,9 @@ typedef struct { #define PROT_ARP 0x0806 /* IP ARP protocol */ #define PROT_RARP 0x8035 /* IP ARP protocol */ +#define IPPROTO_ICMP 1 /* Internet Control Message Protocol */ +#define IPPROTO_UDP 17 /* User Datagram Protocol */ + /* * Internet Protocol (IP) header. */ @@ -142,6 +145,33 @@ typedef struct #define ARP_HDR_SIZE (8+20) /* Size assuming ethernet */ +/* + * ICMP stuff (just enough to handle (host) redirect messages) + */ +#define ICMP_REDIRECT 5 /* Redirect (change route) */ + +/* Codes for REDIRECT. */ +#define ICMP_REDIR_NET 0 /* Redirect Net */ +#define ICMP_REDIR_HOST 1 /* Redirect Host */ + +typedef struct icmphdr { + uchar type; + uchar code; + ushort checksum; + union { + struct { + ushort id; + ushort sequence; + } echo; + ulong gateway; + struct { + ushort __unused; + ushort mtu; + } frag; + } un; +} ICMP_t; + + /* * Maximum packet size; used to allocate packet storage. diff --git a/include/ppcboot.h b/include/ppcboot.h index 32b8df9..a0586d2 100644 --- a/include/ppcboot.h +++ b/include/ppcboot.h @@ -184,7 +184,7 @@ void pci_init (void); void pciinfo (int); #endif -#if defined(CONFIG_COGENT) || defined(CONFIG_SXNI855T) +#if defined(CONFIG_COGENT) || defined(CONFIG_SXNI855T) || defined(CONFIG_RSD_PROTO) /* cogent - $(BOARD)/mb.c */ /* SXNI855T - $(BOARD)/$(BOARD).c */ int misc_init_f (void); diff --git a/net/arp.c b/net/arp.c index c9fffdb..59853f3 100644 --- a/net/arp.c +++ b/net/arp.c @@ -85,7 +85,9 @@ ArpRequest (void) for (i=10; i<16; ++i) { arp->ar_data[i] = 0; /* dest ET addr = 0 */ } - *(IPaddr_t *)(&arp->ar_data[16]) = NetServerIP; /* dest IP addr */ + *(IPaddr_t *)(&arp->ar_data[16]) = /* dest IP addr */ + (NetOurGatewayIP) ? NetOurGatewayIP /* => Gateway */ + : NetServerIP; /* => TFTP server */ NetSendPacket(NetTxPacket, ETHER_HDR_SIZE + ARP_HDR_SIZE); diff --git a/net/net.c b/net/net.c index e841649..dd01d17 100644 --- a/net/net.c +++ b/net/net.c @@ -326,9 +326,9 @@ NetReceive(volatile uchar * pkt, int len) * - REQUEST packets will be answered by sending our * IP address - if we know it. * - REPLY packates are expected only after we asked - * for the TFTP server's ethernet address; so if we - * receive such a packet, we set the server - * ethernet address + * for the TFTP server's or the gateway's ethernet + * address; so if we receive such a packet, we set + * the server ethernet address */ #ifdef ET_DEBUG printf("Got ARP\n"); @@ -372,7 +372,7 @@ NetReceive(volatile uchar * pkt, int len) return; case ARPOP_REPLY: /* set TFTP server eth addr */ #ifdef ET_DEBUG - printf("Got ARP REPLY, set TFTP server eth addr\n"); + printf("Got ARP REPLY, set server/gtwy eth addr\n"); #endif NetCopyEther(NetServerEther, &arp->ar_data[0]); (*packetHandler)(0,0,0,0); /* start TFTP */ @@ -433,19 +433,36 @@ NetReceive(volatile uchar * pkt, int len) } if (NetOurIP && ip->ip_dst != NetOurIP) return; - if (ip->ip_p != 17) /* Only UDP packets */ - return; - - - /* - * At this point we still use the ET broadcast - * address; copy the server ET adress to the req. - * location. This happens when issuing a TFTP request - * with the known server IP address and the ET - * broadcast address as destination. + /* + * watch for ICMP host redirects + * + * There is no real handler code (yet). We just watch + * for ICMP host redirect messages. In case anybody + * sees these messages: please contact me + * (wd@denx.de), or - even better - send me the + * necessary fixes :-) + * + * Note: in all cases where I have seen this so far + * it was a problem with the router configuration, + * for instance when a router was configured in the + * BOOTP reply, but the TFTP server was on the same + * subnet. So this is probably a warning that your + * configuration might be wrong. But I'm not really + * sure if there aren't any other situations. */ - if (memcmp(NetServerEther, NetBcastAddr, 6) == 0) - NetCopyEther(NetServerEther, et->et_src); + if (ip->ip_p == IPPROTO_ICMP) { + ICMP_t *icmph = (ICMP_t *)&(ip->udp_src); + + if (icmph->type != ICMP_REDIRECT) + return; + if (icmph->code != ICMP_REDIR_HOST) + return; + puts (" ICMP Host Redirect to "); + print_IPaddr(icmph->un.gateway); + putc(' '); + } else if (ip->ip_p != IPPROTO_UDP) { /* Only UDP packets */ + return; + } /* * IP header OK. Pass the packet to the current handler. diff --git a/net/tftp.c b/net/tftp.c index 2a8f3d4..33a2969 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -117,19 +117,23 @@ TftpSend (void) static void TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) { - if (dest != TftpOurPort) + if (dest != TftpOurPort) { return; - if (TftpState != STATE_RRQ && src != TftpServerPort) + } + if (TftpState != STATE_RRQ && src != TftpServerPort) { return; + } - if (len < 2) + if (len < 2) { return; + } len -= 2; switch (SWAP16(*((ushort *)pkt)++)) { case TFTP_RRQ: case TFTP_WRQ: case TFTP_ACK: + break; default: break;