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