diff options
author | wdenk <wdenk> | 2003-10-06 21:55:32 +0000 |
---|---|---|
committer | wdenk <wdenk> | 2003-10-06 21:55:32 +0000 |
commit | fbe4b5cbdea438ccec0d93de443f367f3ba46196 (patch) | |
tree | 7a0a65dbae5217950bcc6301a435a074263fa0a7 /net | |
parent | bb65a312675f3cd1923a5cbe325ad9ca1703fc58 (diff) | |
download | u-boot-imx-fbe4b5cbdea438ccec0d93de443f367f3ba46196.zip u-boot-imx-fbe4b5cbdea438ccec0d93de443f367f3ba46196.tar.gz u-boot-imx-fbe4b5cbdea438ccec0d93de443f367f3ba46196.tar.bz2 |
* Update TRAB auto update code
* Make fatload set filesize environment variable
fix potential buffer overlow problem
* enable basic / medium / high-end configurations for PPChameleonEVB
board; fix NAND code
* enable TFTP client code to specify to the server the desired
timeout value (see RFC-2349)
Diffstat (limited to 'net')
-rw-r--r-- | net/tftp.c | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -15,7 +15,7 @@ #if (CONFIG_COMMANDS & CFG_CMD_NET) #define WELL_KNOWN_PORT 69 /* Well known TFTP port # */ -#define TIMEOUT 2 /* Seconds to timeout for a lost pkt */ +#define TIMEOUT 5 /* Seconds to timeout for a lost pkt */ #ifndef CONFIG_NET_RETRY_COUNT # define TIMEOUT_COUNT 10 /* # of timeouts before giving up */ #else @@ -32,6 +32,7 @@ #define TFTP_DATA 3 #define TFTP_ACK 4 #define TFTP_ERROR 5 +#define TFTP_OACK 6 static int TftpServerPort; /* The UDP port at their end */ @@ -44,6 +45,7 @@ static int TftpState; #define STATE_DATA 2 #define STATE_TOO_LARGE 3 #define STATE_BAD_MAGIC 4 +#define STATE_OACK 5 #define DEFAULT_NAME_LEN (8 + 4 + 1) static char default_filename[DEFAULT_NAME_LEN]; @@ -113,10 +115,18 @@ TftpSend (void) pkt += strlen(tftp_filename) + 1; strcpy ((char *)pkt, "octet"); pkt += 5 /*strlen("octet")*/ + 1; + strcpy ((char *)pkt, "timeout"); + pkt += 7 /*strlen("timeout")*/ + 1; + sprintf((char *)pkt, "%d", TIMEOUT); +#ifdef ET_DEBUG + printf("send option \"timeout %s\"\n", (char *)pkt); +#endif + pkt += strlen((char *)pkt) + 1; len = pkt - xp; break; case STATE_DATA: + case STATE_OACK: xp = pkt; *((ushort *)pkt)++ = htons(TFTP_ACK); *((ushort *)pkt)++ = htons(TftpBlock); @@ -173,6 +183,14 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) default: break; + case TFTP_OACK: +#ifdef ET_DEBUG + printf("Got OACK: %s %s\n", pkt, pkt+strlen(pkt)+1); +#endif + TftpState = STATE_OACK; + TftpServerPort = src; + TftpSend (); /* Send ACK */ + break; case TFTP_DATA: if (len < 2) return; @@ -184,7 +202,13 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) puts ("\n\t "); } +#ifdef ET_DEBUG if (TftpState == STATE_RRQ) { + printf("Server did not acknowledge timeout option!\n"); + } +#endif + + if (TftpState == STATE_RRQ || TftpState == STATE_OACK) { TftpState = STATE_DATA; TftpServerPort = src; TftpLastBlock = 0; @@ -305,6 +329,7 @@ TftpStart (void) TftpTimeoutCount = 0; TftpState = STATE_RRQ; TftpOurPort = 1024 + (get_timer(0) % 3072); + TftpBlock = 0; /* zero out server ether in case the server ip has changed */ memset(NetServerEther, 0, 6); |