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 write 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 * @see TFTPPacket
40 * @see TFTPRequestPacket
41 * @see TFTPPacketException
42 * @see TFTP
43 ***/
44
45 public final class TFTPWriteRequestPacket extends TFTPRequestPacket
46 {
47
48 /***
49 * Creates a write request packet to be sent to a host at a
50 * given port with a filename and transfer mode request.
51 * <p>
52 * @param destination The host to which the packet is going to be sent.
53 * @param port The port to which the packet is going to be sent.
54 * @param filename The requested filename.
55 * @param mode The requested transfer mode. This should be on of the TFTP
56 * class MODE constants (e.g., TFTP.NETASCII_MODE).
57 ***/
58 public TFTPWriteRequestPacket(InetAddress destination, int port,
59 String filename, int mode)
60 {
61 super(destination, port, TFTPPacket.WRITE_REQUEST, filename, mode);
62 }
63
64 /***
65 * Creates a write request packet of based on a received
66 * datagram and assumes the datagram has already been identified as a
67 * write request. Assumes the datagram is at least length 4, else an
68 * ArrayIndexOutOfBoundsException may be thrown.
69 * <p>
70 * @param datagram The datagram containing the received request.
71 * @throws TFTPPacketException If the datagram isn't a valid TFTP
72 * request packet.
73 ***/
74 TFTPWriteRequestPacket(DatagramPacket datagram) throws TFTPPacketException
75 {
76 super(TFTPPacket.WRITE_REQUEST, datagram);
77 }
78 }