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