1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.net.tftp;
  17. import java.net.DatagramPacket;
  18. import java.net.InetAddress;
  19. /***
  20. * A class derived from TFTPRequestPacket definiing a TFTP read request
  21. * packet type.
  22. * <p>
  23. * Details regarding the TFTP protocol and the format of TFTP packets can
  24. * be found in RFC 783. But the point of these classes is to keep you
  25. * from having to worry about the internals. Additionally, only very
  26. * few people should have to care about any of the TFTPPacket classes
  27. * or derived classes. Almost all users should only be concerned with the
  28. * <a href="org.apache.commons.net.tftp.TFTPClient.html#_top_">TFTPClient</a> class
  29. * <a href="org.apache.commons.net.tftp.TFTPClient.html#receiveFile">receiveFile()</a>
  30. * and
  31. * <a href="org.apache.commons.net.tftp.TFTPClient.html#sendFile">sendFile()</a>
  32. * methods.
  33. * <p>
  34. * <p>
  35. * @author Daniel F. Savarese
  36. * @see TFTPPacket
  37. * @see TFTPRequestPacket
  38. * @see TFTPPacketException
  39. * @see TFTP
  40. ***/
  41. public final class TFTPReadRequestPacket extends TFTPRequestPacket
  42. {
  43. /***
  44. * Creates a read request packet to be sent to a host at a
  45. * given port with a filename and transfer mode request.
  46. * <p>
  47. * @param destination The host to which the packet is going to be sent.
  48. * @param port The port to which the packet is going to be sent.
  49. * @param filename The requested filename.
  50. * @param mode The requested transfer mode. This should be on of the TFTP
  51. * class MODE constants (e.g., TFTP.NETASCII_MODE).
  52. ***/
  53. public TFTPReadRequestPacket(InetAddress destination, int port,
  54. String filename, int mode)
  55. {
  56. super(destination, port, TFTPPacket.READ_REQUEST, filename, mode);
  57. }
  58. /***
  59. * Creates a read request packet of based on a received
  60. * datagram and assumes the datagram has already been identified as a
  61. * read request. Assumes the datagram is at least length 4, else an
  62. * ArrayIndexOutOfBoundsException may be thrown.
  63. * <p>
  64. * @param datagram The datagram containing the received request.
  65. * @throws TFTPPacketException If the datagram isn't a valid TFTP
  66. * request packet.
  67. ***/
  68. TFTPReadRequestPacket(DatagramPacket datagram) throws TFTPPacketException
  69. {
  70. super(TFTPPacket.READ_REQUEST, datagram);
  71. }
  72. }