01: /*
02: * Copyright 2001-2005 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 write 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 TFTPWriteRequestPacket extends TFTPRequestPacket {
45:
46: /***
47: * Creates a write request packet to be sent to a host at a
48: * given port with a filename and transfer mode request.
49: * <p>
50: * @param destination The host to which the packet is going to be sent.
51: * @param port The port to which the packet is going to be sent.
52: * @param filename The requested filename.
53: * @param mode The requested transfer mode. This should be on of the TFTP
54: * class MODE constants (e.g., TFTP.NETASCII_MODE).
55: ***/
56: public TFTPWriteRequestPacket(InetAddress destination, int port,
57: String filename, int mode) {
58: super (destination, port, TFTPPacket.WRITE_REQUEST, filename,
59: mode);
60: }
61:
62: /***
63: * Creates a write request packet of based on a received
64: * datagram and assumes the datagram has already been identified as a
65: * write request. Assumes the datagram is at least length 4, else an
66: * ArrayIndexOutOfBoundsException may be thrown.
67: * <p>
68: * @param datagram The datagram containing the received request.
69: * @throws TFTPPacketException If the datagram isn't a valid TFTP
70: * request packet.
71: ***/
72: TFTPWriteRequestPacket(DatagramPacket datagram)
73: throws TFTPPacketException {
74: super(TFTPPacket.WRITE_REQUEST, datagram);
75: }
76: }
|