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
+2 -41
View File
@@ -33,10 +33,6 @@
*
****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/****************************************************************************
* 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 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 */
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.
*/
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
ablockno = CONFIG_NETUTILS_TFTP_ACKPACKETS-1;
#endif
do
{
/* Increment the TFTP block number for the next transfer */
@@ -301,35 +289,8 @@ int tftpget(const char *remote, const char *local, in_addr_t addr, boolean binar
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);
ret = tftp_sendto(sd, packet, len, &server);
if (ret != len)
{
goto errout_with_sd;
}
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
lastacked = blockno;
#endif
nvdbg("ACK blockno %d\n", blockno);
}
}
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)
@@ -338,7 +299,7 @@ int tftpget(const char *remote, const char *local, in_addr_t addr, boolean binar
}
nvdbg("ACK blockno %d\n", blockno);
}
#endif
while (ndatabytes >= TFTP_DATASIZE);
/* Return success */
+6 -12
View File
@@ -54,18 +54,10 @@
* then default values are assigned here.
*/
/* Number of packets before ACK is returned */
#ifndef CONFIG_NETUTILS_TFTP_ACKPACKETS
# 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) */
/* The "well-known" server TFTP port number (usually 69). This port number
* is only used for the initial server contact. The server will negotiate
* a new transfer port number after the initial client request.
*/
#ifndef CONFIG_NETUTILS_TFTP_PORT
# define CONFIG_NETUTILS_TFTP_PORT 69
@@ -77,6 +69,8 @@
# define CONFIG_NETUTILS_TFTP_TIMEOUT 10 /* One second */
#endif
/* Sizes of TFTP messsage headers */
#define TFTP_ACKHEADERSIZE 4
#define TFTP_ERRHEADERSIZE 4
#define TFTP_DATAHEADERSIZE 4
-4
View File
@@ -33,10 +33,6 @@
*
****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
+40 -175
View File
@@ -33,10 +33,6 @@
*
****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
@@ -74,21 +70,6 @@
* 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
****************************************************************************/
@@ -281,7 +262,7 @@ static int tftp_rcvack(int sd, ubyte *packet, struct sockaddr_in *server,
if (opcode != TFTP_ACK)
{
nvdbg("Bad opcode%d\n");
nvdbg("Bad opcode\n");
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET)
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)
{
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 */
off_t offset; /* Offset into source file */
uint16 blockno = 0; /* The current transfer block number */
uint16 rblockno; /* The ACK'ed block number */
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 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 */
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.
*/
for (retry = 0; retry < TFTP_RETRIES; retry++)
retry = 0;
for (;;)
{
packetlen = tftp_mkreqpacket(packet, TFTP_WRQ, remote, binary);
ret = tftp_sendto(sd, packet, packetlen, &server);
@@ -407,170 +378,66 @@ int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binar
}
ndbg("Re-sending request\n");
/* We are going to loop and re-send the request packet. Check the
* retry count so that we do not loop forever.
*/
if (++retry > TFTP_RETRIES)
{
ndbg("Retry count exceeded\n");
errno = ETIMEDOUT;
goto errout_with_sd;
}
}
/* Then loop sending the entire file to the server in chunks */
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
head = 0;
tail = 0;
offsets[0] = 0;
hblockno = 1;
#else
offset = 0;
next = 0;
retry = 0;
#endif
for (;;)
{
if (!eof)
/* Construct the next data packet */
packetlen = tftp_mkdatapacket(fd, offset, packet, blockno);
if (packetlen < 0)
{
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
/* Construct the next data packet */
packetlen = tftp_mkdatapacket(fd, offsets[tail], packet, blockno);
if (packetlen < 0)
{
goto errout_with_sd;
}
/* Check for end of file */
if (packetlen < TFTP_PACKETSIZE)
{
eof = TRUE;
}
/* Update counts */
blockno++;
/* Increment the tail (and probably the tail) index of the
* cicular offset list.
*/
tmp = tail;
tail = tftp_incrndx(tail);
/* Make sure that incrementing the tail doesn't make the
* buffer appear empty.
*/
if (head == tail)
{
head = tftp_incrndx(head);
hblockno++;
}
/* Now calculate the next file offset */
offsets[tail] = offsets[tmp] + packetlen;
#else
/* Construct the next data packet */
packetlen = tftp_mkdatapacket(fd, offset, packet, blockno);
if (packetlen < 0)
{
goto errout_with_sd;
}
/* Check for end of file */
if (packetlen < TFTP_PACKETSIZE)
{
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;
}
goto errout_with_sd;
}
/* Check for an ACK for any of the preceding data chunks */
/* Send the next data chunk */
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
if (blockno - hblockno >= CONFIG_NETUTILS_TFTP_ACKPACKETS || eof)
ret = tftp_sendto(sd, packet, packetlen, &server);
if (ret != packetlen)
{
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;
}
}
goto errout_with_sd;
}
#else
/* Get the next ACK from the wire */
/* Check for an ACK for the data chunk */
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.
* file offset).
*/
if (rblockno == blockno)
{
/* Yes.. set up for the next block */
/* Yes.. If we are at the end of the file and if all of the packets
* have been ACKed, then we are done.
*/
if (packetlen < TFTP_PACKETSIZE)
{
break;
}
/* Not the last block.. set up for the next block */
blockno++;
offset = next;
offset += TFTP_DATASIZE;
retry = 0;
/* Skip the retry test */
@@ -579,9 +446,8 @@ int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binar
}
}
/* 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.
/* We are going to loop and re-send the data packet. Check the retry
* count so that we do not loop forever.
*/
if (++retry > TFTP_RETRIES)
@@ -590,7 +456,6 @@ int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binar
errno = ETIMEDOUT;
goto errout_with_sd;
}
#endif
}
/* Return success */