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 *
038 *
039 * @see TFTPPacket
040 * @see TFTPRequestPacket
041 * @see TFTPPacketException
042 * @see TFTP
043 ***/
044
045public final class TFTPReadRequestPacket extends TFTPRequestPacket
046{
047
048    /***
049     * Creates a read request packet to be sent to a host at a
050     * given port with a filename and transfer mode request.
051     *
052     * @param destination  The host to which the packet is going to be sent.
053     * @param port  The port to which the packet is going to be sent.
054     * @param filename The requested filename.
055     * @param mode The requested transfer mode.  This should be on of the TFTP
056     *        class MODE constants (e.g., TFTP.NETASCII_MODE).
057     ***/
058    public TFTPReadRequestPacket(InetAddress destination, int port,
059                                 String filename, int mode)
060    {
061        super(destination, port, TFTPPacket.READ_REQUEST, filename, mode);
062    }
063
064    /***
065     * Creates a read request packet of based on a received
066     * datagram and assumes the datagram has already been identified as a
067     * read request.  Assumes the datagram is at least length 4, else an
068     * ArrayIndexOutOfBoundsException may be thrown.
069     *
070     * @param datagram  The datagram containing the received request.
071     * @throws TFTPPacketException  If the datagram isn't a valid TFTP
072     *         request packet.
073     ***/
074    TFTPReadRequestPacket(DatagramPacket datagram) throws TFTPPacketException
075    {
076        super(TFTPPacket.READ_REQUEST, datagram);
077    }
078
079}