Remove non-standard option

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@889 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2008-09-07 01:27:42 +00:00
parent 97d9b0f075
commit 5e4dfe0d21
4 changed files with 48 additions and 232 deletions
+1 -40
View File
@@ -33,10 +33,6 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@@ -163,11 +159,6 @@ int tftpget(const char *remote, const char *local, in_addr_t addr, boolean binar
int result = ERROR; /* Assume failure */ int result = ERROR; /* Assume failure */
int ret; /* Generic return status */ int ret; /* Generic return status */
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
uint16 lastacked = 0; /* The last block number that was ACK'ed */
int ablockno; /* Number of un-ACKed packets */
#endif
/* Allocate the buffer to used for socket/disk I/O */ /* Allocate the buffer to used for socket/disk I/O */
packet = (ubyte*)zalloc(TFTP_IOBUFSIZE); packet = (ubyte*)zalloc(TFTP_IOBUFSIZE);
@@ -215,9 +206,6 @@ int tftpget(const char *remote, const char *local, in_addr_t addr, boolean binar
* been received or until an error occurs. * been received or until an error occurs.
*/ */
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
ablockno = CONFIG_NETUTILS_TFTP_ACKPACKETS-1;
#endif
do do
{ {
/* Increment the TFTP block number for the next transfer */ /* Increment the TFTP block number for the next transfer */
@@ -301,45 +289,18 @@ int tftpget(const char *remote, const char *local, in_addr_t addr, boolean binar
goto errout_with_sd; goto errout_with_sd;
} }
/* Send the acknowledgment if we have reach the configured block count */ /* Send the acknowledgment */
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
ablockno++;
if (ablockno == CONFIG_NETUTILS_TFTP_ACKPACKETS)
#endif
{
len = tftp_mkackpacket(packet, blockno); len = tftp_mkackpacket(packet, blockno);
ret = tftp_sendto(sd, packet, len, &server); ret = tftp_sendto(sd, packet, len, &server);
if (ret != len) if (ret != len)
{ {
goto errout_with_sd; goto errout_with_sd;
} }
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
lastacked = blockno;
#endif
nvdbg("ACK blockno %d\n", blockno); nvdbg("ACK blockno %d\n", blockno);
} }
}
while (ndatabytes >= TFTP_DATASIZE); while (ndatabytes >= TFTP_DATASIZE);
/* The final packet of the transfer will be a partial packet
*
* If the final packet(s) were not ACK'ed, then we will ACK them here
*/
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
if (ndatabytes < TFTP_DATASIZE && blockno != lastacked)
{
len = tftp_mkackpacket(packet, blockno);
ret = tftp_sendto(sd, packet, len, &server);
if (ret != len)
{
goto errout_with_sd;
}
nvdbg("ACK blockno %d\n", blockno);
}
#endif
/* Return success */ /* Return success */
result = OK; result = OK;
+6 -12
View File
@@ -54,18 +54,10 @@
* then default values are assigned here. * then default values are assigned here.
*/ */
/* Number of packets before ACK is returned */ /* The "well-known" server TFTP port number (usually 69). This port number
* is only used for the initial server contact. The server will negotiate
#ifndef CONFIG_NETUTILS_TFTP_ACKPACKETS * a new transfer port number after the initial client request.
# define CONFIG_NETUTILS_TFTP_ACKPACKETS 1 */
#endif
#define TFTP_MAXACKPACKETS 16
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > TFTP_MAXACKPACKETS
# error "CONFIG_NETUTILS_TFTP_ACKPACKETS exceeds maximum"
#endif
/* The TFTP port number (usually 69) */
#ifndef CONFIG_NETUTILS_TFTP_PORT #ifndef CONFIG_NETUTILS_TFTP_PORT
# define CONFIG_NETUTILS_TFTP_PORT 69 # define CONFIG_NETUTILS_TFTP_PORT 69
@@ -77,6 +69,8 @@
# define CONFIG_NETUTILS_TFTP_TIMEOUT 10 /* One second */ # define CONFIG_NETUTILS_TFTP_TIMEOUT 10 /* One second */
#endif #endif
/* Sizes of TFTP messsage headers */
#define TFTP_ACKHEADERSIZE 4 #define TFTP_ACKHEADERSIZE 4
#define TFTP_ERRHEADERSIZE 4 #define TFTP_ERRHEADERSIZE 4
#define TFTP_DATAHEADERSIZE 4 #define TFTP_DATAHEADERSIZE 4
-4
View File
@@ -33,10 +33,6 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
+73 -208
View File
@@ -33,10 +33,6 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@@ -74,21 +70,6 @@
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Name: tftp_incrndx
****************************************************************************/
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
static inline int tftp_incrndx(int ndx)
{
if (++ndx >= TFTP_MAXACKPACKETS)
{
ndx = 0;
}
return ndx;
}
#endif
/**************************************************************************** /****************************************************************************
* Name: tftp_read * Name: tftp_read
****************************************************************************/ ****************************************************************************/
@@ -281,7 +262,7 @@ static int tftp_rcvack(int sd, ubyte *packet, struct sockaddr_in *server,
if (opcode != TFTP_ACK) if (opcode != TFTP_ACK)
{ {
nvdbg("Bad opcode%d\n"); nvdbg("Bad opcode\n");
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) #if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET)
if (opcode == TFTP_ERR) if (opcode == TFTP_ERR)
{ {
@@ -334,8 +315,8 @@ static int tftp_rcvack(int sd, ubyte *packet, struct sockaddr_in *server,
int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binary) int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binary)
{ {
struct sockaddr_in server; /* The address of the TFTP server */ struct sockaddr_in server; /* The address of the TFTP server */
boolean eof = FALSE; /* TRUE: at end of file */
ubyte *packet; /* Allocated memory to hold one packet */ ubyte *packet; /* Allocated memory to hold one packet */
off_t offset; /* Offset into source file */
uint16 blockno = 0; /* The current transfer block number */ uint16 blockno = 0; /* The current transfer block number */
uint16 rblockno; /* The ACK'ed block number */ uint16 rblockno; /* The ACK'ed block number */
uint16 port = 0; /* This is the port number for the transfer */ uint16 port = 0; /* This is the port number for the transfer */
@@ -346,17 +327,6 @@ int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binar
int result = ERROR; /* Assume failure */ int result = ERROR; /* Assume failure */
int ret; /* Generic return status */ int ret; /* Generic return status */
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
off_t offsets[TFTP_MAXACKPACKETS]; /* Offsets into source file (circular) */
int head; /* Head index into offsets[] */
int tail; /* Tail index into offsets[] */
int hblockno; /* Block number at the head of offsets[] */
int tmp; /* For temporary usage */
#else
off_t offset; /* Offset into source file */
off_t next; /* Offset to the next block */
#endif
/* Allocate the buffer to used for socket/disk I/O */ /* Allocate the buffer to used for socket/disk I/O */
packet = (ubyte*)zalloc(TFTP_IOBUFSIZE); packet = (ubyte*)zalloc(TFTP_IOBUFSIZE);
@@ -390,7 +360,8 @@ int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binar
* of droppying packets if there is nothing hit in the ARP table. * of droppying packets if there is nothing hit in the ARP table.
*/ */
for (retry = 0; retry < TFTP_RETRIES; retry++) retry = 0;
for (;;)
{ {
packetlen = tftp_mkreqpacket(packet, TFTP_WRQ, remote, binary); packetlen = tftp_mkreqpacket(packet, TFTP_WRQ, remote, binary);
ret = tftp_sendto(sd, packet, packetlen, &server); ret = tftp_sendto(sd, packet, packetlen, &server);
@@ -407,181 +378,76 @@ int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binar
} }
ndbg("Re-sending request\n"); ndbg("Re-sending request\n");
}
/* Then loop sending the entire file to the server in chunks */ /* We are going to loop and re-send the request packet. Check the
* retry count so that we do not loop forever.
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1 */
head = 0;
tail = 0; if (++retry > TFTP_RETRIES)
offsets[0] = 0; {
hblockno = 1; ndbg("Retry count exceeded\n");
#else errno = ETIMEDOUT;
offset = 0; goto errout_with_sd;
next = 0; }
retry = 0; }
#endif
/* Then loop sending the entire file to the server in chunks */
for (;;)
{ offset = 0;
if (!eof) retry = 0;
{
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1 for (;;)
/* Construct the next data packet */ {
/* Construct the next data packet */
packetlen = tftp_mkdatapacket(fd, offsets[tail], packet, blockno);
if (packetlen < 0) packetlen = tftp_mkdatapacket(fd, offset, packet, blockno);
{ if (packetlen < 0)
goto errout_with_sd; {
} goto errout_with_sd;
}
/* Check for end of file */
/* Send the next data chunk */
if (packetlen < TFTP_PACKETSIZE)
{ ret = tftp_sendto(sd, packet, packetlen, &server);
eof = TRUE; if (ret != packetlen)
} {
goto errout_with_sd;
/* Update counts */ }
blockno++; /* Check for an ACK for the data chunk */
/* Increment the tail (and probably the tail) index of the if (tftp_rcvack(sd, packet, &server, &port, &rblockno) == OK)
* cicular offset list. {
*/ /* Check if the packet that we just sent was ACK'ed. If not,
* we just loop to resend the same packet (same blockno, same
tmp = tail; * file offset).
tail = tftp_incrndx(tail); */
/* Make sure that incrementing the tail doesn't make the if (rblockno == blockno)
* buffer appear empty. {
*/ /* Yes.. If we are at the end of the file and if all of the packets
* have been ACKed, then we are done.
if (head == tail) */
{
head = tftp_incrndx(head); if (packetlen < TFTP_PACKETSIZE)
hblockno++; {
} break;
}
/* Now calculate the next file offset */
/* Not the last block.. set up for the next block */
offsets[tail] = offsets[tmp] + packetlen;
#else blockno++;
/* Construct the next data packet */ offset += TFTP_DATASIZE;
retry = 0;
packetlen = tftp_mkdatapacket(fd, offset, packet, blockno);
if (packetlen < 0) /* Skip the retry test */
{
goto errout_with_sd; continue;
} }
}
/* Check for end of file */
/* We are going to loop and re-send the data packet. Check the retry
if (packetlen < TFTP_PACKETSIZE) * count so that we do not loop forever.
{
eof = TRUE;
}
/* Now calculate the next file offset */
next = offset + packetlen;
#endif
/* Send the next data block */
ret = tftp_sendto(sd, packet, packetlen, &server);
if (ret != packetlen)
{
goto errout_with_sd;
}
}
/* Check for an ACK for any of the preceding data chunks */
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
if (blockno - hblockno >= CONFIG_NETUTILS_TFTP_ACKPACKETS || eof)
{
int ndx;
/* Get the next ACK from the wire */
if (tftp_rcvack(sd, packet, &server, &port, &rblockno) == OK)
{
while (hblockno < rblockno && tail != head)
{
head = tftp_incrndx(head);
hblockno++;
}
}
/* If we are at the end of the file and if all of the packets
* have been ACKed, then we are done.
*/
if (eof && head == tail)
{
break;
}
/* Otherwise, resend all un-acknowledged packets */
for (ndx = head, rblockno = hblockno;
ndx != tail;
ndx = tftp_incrndx(ndx), hblockno++)
{
/* Format the data packet, re-reading the data from the file */
packetlen = tftp_mkdatapacket(fd, offsets[ndx], packet, rblockno);
if (packetlen < 0)
{
goto errout_with_sd;
}
/* Re-send the data packet */
ret = tftp_sendto(sd, packet, packetlen, &server);
if (ret != packetlen)
{
goto errout_with_sd;
}
}
}
#else
/* Get the next ACK from the wire */
if (tftp_rcvack(sd, packet, &server, &port, &rblockno) == OK)
{
/* If we are at the end of the file and if all of the packets
* have been ACKed, then we are done.
*/
if (eof)
{
break;
}
/* Check if the packet that we just sent was ACK'ed. If not,
* we just loop to resend the same packet (same blockno, same
* file offset.
*/
if (rblockno == blockno)
{
/* Yes.. set up for the next block */
blockno++;
offset = next;
retry = 0;
/* Skip the retry test */
continue;
}
}
/* We are going to loop and (probably) re-send the data packet and
* certainly try to receive the ACK packet. Check the retry count
* so that we do not loop forever.
*/ */
if (++retry > TFTP_RETRIES) if (++retry > TFTP_RETRIES)
@@ -590,7 +456,6 @@ int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binar
errno = ETIMEDOUT; errno = ETIMEDOUT;
goto errout_with_sd; goto errout_with_sd;
} }
#endif
} }
/* Return success */ /* Return success */