summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2001-12-07 12:59:12 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2001-12-07 12:59:12 +0000
commit86d9ca28ed8db331267d1d6b4b727df339359aa6 (patch)
tree457d9e377c49f6240636c092e5d8f03a636e2855
parent85ca7699a7a312081f4e7f78534ca12f4dd4088b (diff)
downloadrtems-86d9ca28ed8db331267d1d6b4b727df339359aa6.tar.bz2
2001-12-07 Eric Norum <eric.norum@usask.ca>
* lib/tftpDriver.c: Restore write capability.
-rw-r--r--c/src/exec/libnetworking/ChangeLog4
-rw-r--r--c/src/exec/libnetworking/lib/tftpDriver.c19
-rw-r--r--c/src/libnetworking/ChangeLog4
-rw-r--r--c/src/libnetworking/lib/tftpDriver.c19
-rw-r--r--cpukit/libnetworking/ChangeLog4
-rw-r--r--cpukit/libnetworking/lib/tftpDriver.c19
6 files changed, 51 insertions, 18 deletions
diff --git a/c/src/exec/libnetworking/ChangeLog b/c/src/exec/libnetworking/ChangeLog
index 4cdc2eb311..b53bf7ff43 100644
--- a/c/src/exec/libnetworking/ChangeLog
+++ b/c/src/exec/libnetworking/ChangeLog
@@ -1,3 +1,7 @@
+2001-12-07 Eric Norum <eric.norum@usask.ca>
+
+ * lib/tftpDriver.c: Restore write capability.
+
2001-11-26 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
* arpa/Makefile.am: Remove stray lines.
diff --git a/c/src/exec/libnetworking/lib/tftpDriver.c b/c/src/exec/libnetworking/lib/tftpDriver.c
index 071ba0012b..bafaaa5fc5 100644
--- a/c/src/exec/libnetworking/lib/tftpDriver.c
+++ b/c/src/exec/libnetworking/lib/tftpDriver.c
@@ -378,7 +378,7 @@ getPacket (struct tftpStream *tp, int retryCount)
}
}
else {
- printf ("TFTP: %d0-byte packet\n", len);
+ printf ("TFTP: %d-byte packet\n", len);
}
}
#endif
@@ -725,9 +725,10 @@ static int rtems_tftp_open_worker(
}
if (tp->writing
&& (opcode == TFTP_OPCODE_ACK)
- && (ntohs (tp->pkbuf.tftpACK.blocknum) == 0)) {
+ && ((ntohs (tp->pkbuf.tftpACK.blocknum) == 0)
+ || (ntohs (tp->pkbuf.tftpACK.blocknum) == 1))) {
tp->nused = 0;
- tp->blocknum = 1;
+ tp->blocknum = ntohs (tp->pkbuf.tftpACK.blocknum);
break;
}
if (opcode == TFTP_OPCODE_ERROR) {
@@ -879,17 +880,22 @@ static int rtems_tftp_flush ( struct tftpStream *tp )
tp->pkbuf.tftpDATA.blocknum = htons (tp->blocknum);
#ifdef RTEMS_TFTP_DRIVER_DEBUG
if (rtems_tftp_driver_debug)
- printf ("TFTP: SEND %d\n", tp->blocknum);
+ printf ("TFTP: SEND %d (%d)\n", tp->blocknum, tp->nused);
#endif
if (sendto (tp->socket, (char *)&tp->pkbuf, wlen, 0,
(struct sockaddr *)&tp->farAddress,
sizeof tp->farAddress) < 0)
return EIO;
rlen = getPacket (tp, retryCount);
+ /*
+ * Our last packet won't necessarily be acknowledged!
+ */
+ if ((rlen < 0) && (tp->nused < sizeof tp->pkbuf.tftpDATA.data))
+ return 0;
if (rlen >= (int)sizeof tp->pkbuf.tftpACK) {
int opcode = ntohs (tp->pkbuf.tftpACK.opcode);
if ((opcode == TFTP_OPCODE_ACK)
- && (ntohs (tp->pkbuf.tftpACK.blocknum) == tp->blocknum)) {
+ && (ntohs (tp->pkbuf.tftpACK.blocknum) == (tp->blocknum + 1))) {
tp->nused = 0;
tp->blocknum++;
return 0;
@@ -993,7 +999,8 @@ static rtems_filesystem_node_types_t rtems_tftp_node_type(
rtems_filesystem_location_info_t *pathloc /* IN */
)
{
- if (pathloc->node_access == NULL)
+ if ((pathloc->node_access == NULL)
+ || (pathloc->node_access == ROOT_NODE_ACCESS))
return RTEMS_FILESYSTEM_MEMORY_FILE;
return RTEMS_FILESYSTEM_DIRECTORY;
}
diff --git a/c/src/libnetworking/ChangeLog b/c/src/libnetworking/ChangeLog
index 4cdc2eb311..b53bf7ff43 100644
--- a/c/src/libnetworking/ChangeLog
+++ b/c/src/libnetworking/ChangeLog
@@ -1,3 +1,7 @@
+2001-12-07 Eric Norum <eric.norum@usask.ca>
+
+ * lib/tftpDriver.c: Restore write capability.
+
2001-11-26 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
* arpa/Makefile.am: Remove stray lines.
diff --git a/c/src/libnetworking/lib/tftpDriver.c b/c/src/libnetworking/lib/tftpDriver.c
index 071ba0012b..bafaaa5fc5 100644
--- a/c/src/libnetworking/lib/tftpDriver.c
+++ b/c/src/libnetworking/lib/tftpDriver.c
@@ -378,7 +378,7 @@ getPacket (struct tftpStream *tp, int retryCount)
}
}
else {
- printf ("TFTP: %d0-byte packet\n", len);
+ printf ("TFTP: %d-byte packet\n", len);
}
}
#endif
@@ -725,9 +725,10 @@ static int rtems_tftp_open_worker(
}
if (tp->writing
&& (opcode == TFTP_OPCODE_ACK)
- && (ntohs (tp->pkbuf.tftpACK.blocknum) == 0)) {
+ && ((ntohs (tp->pkbuf.tftpACK.blocknum) == 0)
+ || (ntohs (tp->pkbuf.tftpACK.blocknum) == 1))) {
tp->nused = 0;
- tp->blocknum = 1;
+ tp->blocknum = ntohs (tp->pkbuf.tftpACK.blocknum);
break;
}
if (opcode == TFTP_OPCODE_ERROR) {
@@ -879,17 +880,22 @@ static int rtems_tftp_flush ( struct tftpStream *tp )
tp->pkbuf.tftpDATA.blocknum = htons (tp->blocknum);
#ifdef RTEMS_TFTP_DRIVER_DEBUG
if (rtems_tftp_driver_debug)
- printf ("TFTP: SEND %d\n", tp->blocknum);
+ printf ("TFTP: SEND %d (%d)\n", tp->blocknum, tp->nused);
#endif
if (sendto (tp->socket, (char *)&tp->pkbuf, wlen, 0,
(struct sockaddr *)&tp->farAddress,
sizeof tp->farAddress) < 0)
return EIO;
rlen = getPacket (tp, retryCount);
+ /*
+ * Our last packet won't necessarily be acknowledged!
+ */
+ if ((rlen < 0) && (tp->nused < sizeof tp->pkbuf.tftpDATA.data))
+ return 0;
if (rlen >= (int)sizeof tp->pkbuf.tftpACK) {
int opcode = ntohs (tp->pkbuf.tftpACK.opcode);
if ((opcode == TFTP_OPCODE_ACK)
- && (ntohs (tp->pkbuf.tftpACK.blocknum) == tp->blocknum)) {
+ && (ntohs (tp->pkbuf.tftpACK.blocknum) == (tp->blocknum + 1))) {
tp->nused = 0;
tp->blocknum++;
return 0;
@@ -993,7 +999,8 @@ static rtems_filesystem_node_types_t rtems_tftp_node_type(
rtems_filesystem_location_info_t *pathloc /* IN */
)
{
- if (pathloc->node_access == NULL)
+ if ((pathloc->node_access == NULL)
+ || (pathloc->node_access == ROOT_NODE_ACCESS))
return RTEMS_FILESYSTEM_MEMORY_FILE;
return RTEMS_FILESYSTEM_DIRECTORY;
}
diff --git a/cpukit/libnetworking/ChangeLog b/cpukit/libnetworking/ChangeLog
index 4cdc2eb311..b53bf7ff43 100644
--- a/cpukit/libnetworking/ChangeLog
+++ b/cpukit/libnetworking/ChangeLog
@@ -1,3 +1,7 @@
+2001-12-07 Eric Norum <eric.norum@usask.ca>
+
+ * lib/tftpDriver.c: Restore write capability.
+
2001-11-26 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
* arpa/Makefile.am: Remove stray lines.
diff --git a/cpukit/libnetworking/lib/tftpDriver.c b/cpukit/libnetworking/lib/tftpDriver.c
index 071ba0012b..bafaaa5fc5 100644
--- a/cpukit/libnetworking/lib/tftpDriver.c
+++ b/cpukit/libnetworking/lib/tftpDriver.c
@@ -378,7 +378,7 @@ getPacket (struct tftpStream *tp, int retryCount)
}
}
else {
- printf ("TFTP: %d0-byte packet\n", len);
+ printf ("TFTP: %d-byte packet\n", len);
}
}
#endif
@@ -725,9 +725,10 @@ static int rtems_tftp_open_worker(
}
if (tp->writing
&& (opcode == TFTP_OPCODE_ACK)
- && (ntohs (tp->pkbuf.tftpACK.blocknum) == 0)) {
+ && ((ntohs (tp->pkbuf.tftpACK.blocknum) == 0)
+ || (ntohs (tp->pkbuf.tftpACK.blocknum) == 1))) {
tp->nused = 0;
- tp->blocknum = 1;
+ tp->blocknum = ntohs (tp->pkbuf.tftpACK.blocknum);
break;
}
if (opcode == TFTP_OPCODE_ERROR) {
@@ -879,17 +880,22 @@ static int rtems_tftp_flush ( struct tftpStream *tp )
tp->pkbuf.tftpDATA.blocknum = htons (tp->blocknum);
#ifdef RTEMS_TFTP_DRIVER_DEBUG
if (rtems_tftp_driver_debug)
- printf ("TFTP: SEND %d\n", tp->blocknum);
+ printf ("TFTP: SEND %d (%d)\n", tp->blocknum, tp->nused);
#endif
if (sendto (tp->socket, (char *)&tp->pkbuf, wlen, 0,
(struct sockaddr *)&tp->farAddress,
sizeof tp->farAddress) < 0)
return EIO;
rlen = getPacket (tp, retryCount);
+ /*
+ * Our last packet won't necessarily be acknowledged!
+ */
+ if ((rlen < 0) && (tp->nused < sizeof tp->pkbuf.tftpDATA.data))
+ return 0;
if (rlen >= (int)sizeof tp->pkbuf.tftpACK) {
int opcode = ntohs (tp->pkbuf.tftpACK.opcode);
if ((opcode == TFTP_OPCODE_ACK)
- && (ntohs (tp->pkbuf.tftpACK.blocknum) == tp->blocknum)) {
+ && (ntohs (tp->pkbuf.tftpACK.blocknum) == (tp->blocknum + 1))) {
tp->nused = 0;
tp->blocknum++;
return 0;
@@ -993,7 +999,8 @@ static rtems_filesystem_node_types_t rtems_tftp_node_type(
rtems_filesystem_location_info_t *pathloc /* IN */
)
{
- if (pathloc->node_access == NULL)
+ if ((pathloc->node_access == NULL)
+ || (pathloc->node_access == ROOT_NODE_ACCESS))
return RTEMS_FILESYSTEM_MEMORY_FILE;
return RTEMS_FILESYSTEM_DIRECTORY;
}