View Javadoc

1   /*
2    * Copyright 2001-2005 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  
18  import java.net.DatagramPacket;
19  import java.net.InetAddress;
20  
21  /***
22   * A class derived from TFTPRequestPacket definiing a TFTP read request
23   * packet type.
24   * <p>
25   * Details regarding the TFTP protocol and the format of TFTP packets can
26   * be found in RFC 783.  But the point of these classes is to keep you
27   * from having to worry about the internals.  Additionally, only very
28   * few people should have to care about any of the TFTPPacket classes
29   * or derived classes.  Almost all users should only be concerned with the
30   * {@link org.apache.commons.net.tftp.TFTPClient} class
31   * {@link org.apache.commons.net.tftp.TFTPClient#receiveFile receiveFile()}
32   * and
33   * {@link org.apache.commons.net.tftp.TFTPClient#sendFile sendFile()}
34   * methods.
35   * <p>
36   * <p>
37   * @author Daniel F. Savarese
38   * @see TFTPPacket
39   * @see TFTPRequestPacket
40   * @see TFTPPacketException
41   * @see TFTP
42   ***/
43  
44  public final class TFTPReadRequestPacket extends TFTPRequestPacket
45  {
46  
47      /***
48       * Creates a read request packet to be sent to a host at a
49       * given port with a filename and transfer mode request.
50       * <p>
51       * @param destination  The host to which the packet is going to be sent.
52       * @param port  The port to which the packet is going to be sent.
53       * @param filename The requested filename.
54       * @param mode The requested transfer mode.  This should be on of the TFTP
55       *        class MODE constants (e.g., TFTP.NETASCII_MODE).
56       ***/
57      public TFTPReadRequestPacket(InetAddress destination, int port,
58                                   String filename, int mode)
59      {
60          super(destination, port, TFTPPacket.READ_REQUEST, filename, mode);
61      }
62  
63      /***
64       * Creates a read request packet of based on a received
65       * datagram and assumes the datagram has already been identified as a
66       * read request.  Assumes the datagram is at least length 4, else an
67       * ArrayIndexOutOfBoundsException may be thrown.
68       * <p>
69       * @param datagram  The datagram containing the received request.
70       * @throws TFTPPacketException  If the datagram isn't a valid TFTP
71       *         request packet.
72       ***/
73      TFTPReadRequestPacket(DatagramPacket datagram) throws TFTPPacketException
74      {
75          super(TFTPPacket.READ_REQUEST, datagram);
76      }
77  
78  }