Index: net/tftp.c =================================================================== RCS file: /cvsroot/u-boot/u-boot/net/tftp.c,v retrieving revision 1.9 diff -p -u -r1.9 tftp.c --- net/tftp.c 15 Apr 2004 21:48:55 -0000 1.9 +++ net/tftp.c 6 Jan 2005 03:20:41 -0000 @@ -24,6 +24,9 @@ /* (for checking the image size) */ #define HASHES_PER_LINE 65 /* Number of "loading" hashes per line */ +#define TFTP_PORT_FROM_ENV 1 /* define this to allow setting the */ + /* TFTP source port in the environment */ + /* variable "tftpourport" */ /* * TFTP operations. */ @@ -301,6 +304,8 @@ TftpTimeout (void) void TftpStart (void) { + char *ep; /* Environment pointer */ + if (BootFile[0] == '\0') { IPaddr_t OurIP = ntohl(NetOurIP); @@ -354,7 +359,13 @@ TftpStart (void) TftpServerPort = WELL_KNOWN_PORT; TftpTimeoutCount = 0; TftpState = STATE_RRQ; + /* Use a pseudo-random port unless a specific port is set */ TftpOurPort = 1024 + (get_timer(0) % 3072); +#if TFTP_PORT_FROM_ENV + if ((ep = getenv("tftpourport")) != NULL) { + TftpOurPort= simple_strtol(ep, NULL, 10); + } +#endif TftpBlock = 0; /* zero out server ether in case the server ip has changed */