001 /* 002 * Copyright 2001-2005 The Apache Software Foundation 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.apache.commons.net.tftp; 017 018 import java.net.DatagramPacket; 019 import java.net.InetAddress; 020 021 /*** 022 * A class derived from TFTPRequestPacket definiing a TFTP write request 023 * packet type. 024 * <p> 025 * Details regarding the TFTP protocol and the format of TFTP packets can 026 * be found in RFC 783. But the point of these classes is to keep you 027 * from having to worry about the internals. Additionally, only very 028 * few people should have to care about any of the TFTPPacket classes 029 * or derived classes. Almost all users should only be concerned with the 030 * {@link org.apache.commons.net.tftp.TFTPClient} class 031 * {@link org.apache.commons.net.tftp.TFTPClient#receiveFile receiveFile()} 032 * and 033 * {@link org.apache.commons.net.tftp.TFTPClient#sendFile sendFile()} 034 * methods. 035 * <p> 036 * <p> 037 * @author Daniel F. Savarese 038 * @see TFTPPacket 039 * @see TFTPRequestPacket 040 * @see TFTPPacketException 041 * @see TFTP 042 ***/ 043 044 public final class TFTPWriteRequestPacket extends TFTPRequestPacket 045 { 046 047 /*** 048 * Creates a write request packet to be sent to a host at a 049 * given port with a filename and transfer mode request. 050 * <p> 051 * @param destination The host to which the packet is going to be sent. 052 * @param port The port to which the packet is going to be sent. 053 * @param filename The requested filename. 054 * @param mode The requested transfer mode. This should be on of the TFTP 055 * class MODE constants (e.g., TFTP.NETASCII_MODE). 056 ***/ 057 public TFTPWriteRequestPacket(InetAddress destination, int port, 058 String filename, int mode) 059 { 060 super(destination, port, TFTPPacket.WRITE_REQUEST, filename, mode); 061 } 062 063 /*** 064 * Creates a write request packet of based on a received 065 * datagram and assumes the datagram has already been identified as a 066 * write request. Assumes the datagram is at least length 4, else an 067 * ArrayIndexOutOfBoundsException may be thrown. 068 * <p> 069 * @param datagram The datagram containing the received request. 070 * @throws TFTPPacketException If the datagram isn't a valid TFTP 071 * request packet. 072 ***/ 073 TFTPWriteRequestPacket(DatagramPacket datagram) throws TFTPPacketException 074 { 075 super(TFTPPacket.WRITE_REQUEST, datagram); 076 } 077 }