From 5400f070e6561f674a7428d0a6c14dbe21ca45d9 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 19 Sep 2001 17:40:37 +0000 Subject: 2001-09-19 Eric Norum * lib/tftpDriver.c: Add some debugging capability. --- cpukit/libnetworking/lib/tftpDriver.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'cpukit/libnetworking/lib/tftpDriver.c') diff --git a/cpukit/libnetworking/lib/tftpDriver.c b/cpukit/libnetworking/lib/tftpDriver.c index 47a896cda7..3c52eee8fd 100644 --- a/cpukit/libnetworking/lib/tftpDriver.c +++ b/cpukit/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) -- cgit v1.2.3