Author: sebb Date: Thu Feb 9 00:09:24 2017 New Revision: 1782283 URL: http://svn.apache.org/viewvc?rev=1782283&view=rev Log: NET-612 Allow TFTP socket IO tracing
Modified: commons/proper/net/trunk/src/changes/changes.xml commons/proper/net/trunk/src/main/java/org/apache/commons/net/tftp/TFTP.java Modified: commons/proper/net/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1782283&r1=1782282&r2=1782283&view=diff ============================================================================== --- commons/proper/net/trunk/src/changes/changes.xml [utf-8] (original) +++ commons/proper/net/trunk/src/changes/changes.xml [utf-8] Thu Feb 9 00:09:24 2017 @@ -87,6 +87,9 @@ without checking it if is a space. The POP3Mail examples can now get password from console, stdin or an environment variable. "> + <action issue="NET-612" type="update" dev="sebb"> + Allow TFTP socket IO tracing + </action> <action issue="NET-596" type="fix" dev="sebb" due-to="Vincent Bories-Azeau"> NullPointerException when disconnecting TelnetClient twice with JDK 7 </action> Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/tftp/TFTP.java URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/tftp/TFTP.java?rev=1782283&r1=1782282&r2=1782283&view=diff ============================================================================== --- commons/proper/net/trunk/src/main/java/org/apache/commons/net/tftp/TFTP.java (original) +++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/tftp/TFTP.java Thu Feb 9 00:09:24 2017 @@ -201,7 +201,9 @@ public class TFTP extends DatagramSocket __receiveDatagram.setLength(__receiveBuffer.length); _socket_.receive(__receiveDatagram); - return TFTPPacket.newTFTPPacket(__receiveDatagram); + TFTPPacket newTFTPPacket = TFTPPacket.newTFTPPacket(__receiveDatagram); + trace("<", newTFTPPacket); + return newTFTPPacket; } /*** @@ -224,6 +226,7 @@ public class TFTP extends DatagramSocket ***/ public final void bufferedSend(TFTPPacket packet) throws IOException { + trace(">", packet); _socket_.send(packet._newDatagram(__sendDatagram, _sendBuffer)); } @@ -266,6 +269,7 @@ public class TFTP extends DatagramSocket ***/ public final void send(TFTPPacket packet) throws IOException { + trace(">", packet); _socket_.send(packet.newDatagram()); } @@ -294,8 +298,15 @@ public class TFTP extends DatagramSocket _socket_.receive(packet); - return TFTPPacket.newTFTPPacket(packet); + TFTPPacket newTFTPPacket = TFTPPacket.newTFTPPacket(packet); + trace("<", newTFTPPacket); + return newTFTPPacket; } + // Override this to trace the packet flow + protected void trace(String direction, TFTPPacket packet) { +// Simple implementation: +// System.out.println(direction + " " + packet.toString()); + } }