summaryrefslogtreecommitdiffstats
path: root/c/src/exec
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2001-09-19 17:40:37 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2001-09-19 17:40:37 +0000
commit5400f070e6561f674a7428d0a6c14dbe21ca45d9 (patch)
treeedb912ff78f2da141690eae63fa613a80c506232 /c/src/exec
parent2001-09-19 Chris Johns <ccj@acm.org> (diff)
downloadrtems-5400f070e6561f674a7428d0a6c14dbe21ca45d9.tar.bz2
2001-09-19 Eric Norum <eric.norum@usask.ca>
* lib/tftpDriver.c: Add some debugging capability.
Diffstat (limited to 'c/src/exec')
-rw-r--r--c/src/exec/libnetworking/ChangeLog4
-rw-r--r--c/src/exec/libnetworking/lib/tftpDriver.c35
2 files changed, 39 insertions, 0 deletions
diff --git a/c/src/exec/libnetworking/ChangeLog b/c/src/exec/libnetworking/ChangeLog
index fa79ed7f87..6ff4ff4fe6 100644
--- a/c/src/exec/libnetworking/ChangeLog
+++ b/c/src/exec/libnetworking/ChangeLog
@@ -1,3 +1,7 @@
+2001-09-19 Eric Norum <eric.norum@usask.ca>
+
+ * lib/tftpDriver.c: Add some debugging capability.
+
2001-09-19 Chris Johns <ccj@acm.org>
* nfs/bootp_subr.c, rtems/rtems_bootp.c, rtems/rtems_bsdnet.h,
diff --git a/c/src/exec/libnetworking/lib/tftpDriver.c b/c/src/exec/libnetworking/lib/tftpDriver.c
index 47a896cda7..3c52eee8fd 100644
--- a/c/src/exec/libnetworking/lib/tftpDriver.c
+++ b/c/src/exec/libnetworking/lib/tftpDriver.c
@@ -35,6 +35,9 @@
do { errno = (_error); return -1; } while(0)
#endif
+#ifdef RTEMS_TFTP_DRIVER_DEBUG
+int rtems_tftp_driver_debug = 1;
+#endif
/*
* Range of UDP ports to try
@@ -349,6 +352,29 @@ getPacket (struct tftpStream *tp, int retryCount)
tv.tv_sec = 0;
tv.tv_usec = 0;
setsockopt (tp->socket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
+#ifdef RTEMS_TFTP_DRIVER_DEBUG
+ if (rtems_tftp_driver_debug) {
+ if (len >= (int) sizeof tp->pkbuf.tftpACK) {
+ int opcode = ntohs (tp->pkbuf.tftpDATA.opcode);
+ switch (opcode) {
+ default:
+ printf ("TFTP: OPCODE %d\n", opcode);
+ break;
+
+ case TFTP_OPCODE_DATA:
+ printf ("TFTP: RECV %d\n", ntohs (tp->pkbuf.tftpDATA.blocknum));
+ break;
+
+ case TFTP_OPCODE_ACK:
+ printf ("TFTP: GOT ACK %d\n", ntohs (tp->pkbuf.tftpACK.blocknum));
+ break;
+ }
+ }
+ else {
+ printf ("TFTP: %d0-byte packet\n", len);
+ }
+ }
+#endif
return len;
}
@@ -358,6 +384,11 @@ getPacket (struct tftpStream *tp, int retryCount)
static int
sendAck (struct tftpStream *tp)
{
+#ifdef RTEMS_TFTP_DRIVER_DEBUG
+ if (rtems_tftp_driver_debug)
+ printf ("TFTP: ACK %d\n", tp->blocknum);
+#endif
+
/*
* Create the acknowledgement
*/
@@ -719,6 +750,10 @@ static int rtems_tftp_flush ( struct tftpStream *tp )
for (;;) {
tp->pkbuf.tftpDATA.opcode = htons (TFTP_OPCODE_DATA);
tp->pkbuf.tftpDATA.blocknum = htons (tp->blocknum);
+#ifdef RTEMS_TFTP_DRIVER_DEBUG
+ if (rtems_tftp_driver_debug)
+ printf ("TFTP: SEND %d\n", tp->blocknum);
+#endif
if (sendto (tp->socket, (char *)&tp->pkbuf, wlen, 0,
(struct sockaddr *)&tp->farAddress,
sizeof tp->farAddress) < 0)