net.sf.hermesftp.cmd.impl
Class FtpCmdEpsv

java.lang.Object
  extended by net.sf.hermesftp.cmd.AbstractFtpCmd
      extended by net.sf.hermesftp.cmd.AbstractFtpCmdPasv
          extended by net.sf.hermesftp.cmd.impl.FtpCmdEpsv
All Implemented Interfaces:
java.lang.Cloneable, FtpCmd, FtpConstants

public class FtpCmdEpsv
extends AbstractFtpCmdPasv

The EPSV Command (EPSV)

The EPSV command requests that a server listen on a data port and wait for a connection. The EPSV command takes an optional argument. The response to this command includes only the TCP port number of the listening connection. The format of the response, however, is similar to the argument of the EPRT command. This allows the same parsing routines to be used for both commands. In addition, the format leaves a place holder for the network protocol and/or network address, which may be needed in the EPSV response in the future. The response code for entering passive mode using an extended address MUST be 229. The interpretation of this code, according to [PR85] is:

   2yz Positive Completion
   x2z Connections
   xy9 Extended Passive Mode Entered
 

The text returned in response to the EPSV command MUST be:

   <text indicating server is entering extended passive mode> 
   (<d><d><d><tcp-port><d>)
 

The portion of the string enclosed in parentheses MUST be the exact string needed by the EPRT command to open the data connection, as specified above.

The first two fields contained in the parenthesis MUST be blank. The third field MUST be the string representation of the TCP port number on which the server is listening for a data connection. The network protocol used by the data connection will be the same network protocol used by the control connection. In addition, the network address used to establish the data connection will be the same network address used for the control connection. An example response string follows:

   Entering Extended Passive Mode (|||6446|)
 

The standard negative error codes 500 and 501 are sufficient to handle all errors involving the EPSV command (e.g., syntax errors). When the EPSV command is issued with no argument, the server will choose the network protocol for the data connection based on the protocol used for the control connection. However, in the case of proxy FTP, this protocol might not be appropriate for communication between the two servers. Therefore, the client needs to be able to request a specific protocol. If the server returns a protocol that is not supported by the host that will be connecting to the port, the client MUST issue an ABOR (abort) command to allow the server to close down the listening connection. The client can then send an EPSV command requesting the use of a specific network protocol, as follows:

   EPSV<space><net-prt>
 

If the requested protocol is supported by the server, it SHOULD use the protocol. If not, the server MUST return the 522 error messages as outlined in section 2.

Finally, the EPSV command can be used with the argument "ALL" to inform Network Address Translators that the EPRT command (as well as other data commands) will no longer be used. An example of this command follows:

EPSV<space>ALL

Upon receipt of an EPSV ALL command, the server MUST reject all data connection setup commands other than EPSV (i.e., EPRT, PORT, PASV, et al.). This use of the EPSV command is further explained in section 4.

[Excerpt from RFC-2428, Allman]


Field Summary
 
Fields inherited from interface net.sf.hermesftp.common.FtpConstants
ATTR_CLIENT_NAME, ATTR_DATA_PROT, ATTR_FILE_OFFSET, ATTR_FORCE_UTF8, ATTR_GROUP_DATA, ATTR_LOGIN_TIME, ATTR_RENAME_FILE, ATTR_RESTART_MARKERS, ATTR_SSL, ATTR_USER_DATA, BYTE_LENGTH, BYTE_MASK, DEFAULT_BEAN_RES, DEFAULT_KEYSTORE, DEFAULT_KEYSTORE_PASS, DT_ASCII, DT_BINARY, DT_EBCDIC, HERMES_HOME, MILLI, MODE_BLOCK, MODE_COMPRESS, MODE_STREAM, MODE_ZIP, MSG_GOODBYE, MSG150, MSG200, MSG200_NOTED, MSG200_PBSZ, MSG200_SIZE, MSG200_TYPE, MSG202, MSG211_FEAT_ENTRY, MSG211_FEAT_FOOTER, MSG211_FEAT_HEADER, MSG211_STAT, MSG213_SIZE, MSG213_TIME, MSG214, MSG220, MSG220_WEL, MSG226, MSG227, MSG229, MSG230, MSG234, MSG250, MSG257, MSG331, MSG350, MSG350_REST, MSG421, MSG425, MSG426, MSG431, MSG450, MSG451, MSG500, MSG500_CMD, MSG501, MSG501_PATH, MSG501_SIZE, MSG503, MSG503_USR, MSG504, MSG522, MSG530, MSG530_AUTH, MSG534, MSG536, MSG550, MSG550_COMM, MSG550_EXISTS, MSG550_MSG, MSG550_NOTEMPTY, MSG550_PERM, MSG553, OPT_ALLOWED_PASSIVE_PORTS, OPT_BUFFER_SIZE, OPT_CHARSET_ASCII, OPT_CHARSET_EBCDIC, OPT_EMULATE_UNIX, OPT_FTP_PORT, OPT_IPV4_BLACK_LIST, OPT_IPV6_BLACK_LIST, OPT_MAX_CONNECTIONS, OPT_MAX_DOWNLOAD_RATE, OPT_MAX_IDLE_SECONDS, OPT_MAX_UPLOAD_RATE, OPT_MSG_GOODBYE, OPT_MSG_WELCOME, OPT_REMOTE_DIR, OPT_SSL_ALLOW_EXPLICIT, OPT_SSL_ALLOW_IMPLICIT, OPT_SSL_CIPHER_SUITES, OPT_SSL_FORCE, OPT_SSL_KEYSTORE_FILE, OPT_SSL_KEYSTORE_PASS, OPT_SSL_PORT_IMPLICIT, PRIV_NONE, PRIV_READ, PRIV_READ_WRITE, PRIV_WRITE, PWD, SEPARATOR, SERVER_STATUS_HALTED, SERVER_STATUS_INIT, SERVER_STATUS_READY, SERVER_STATUS_UNDEF, SPACE, STAT_BYTES_DOWNLOADED, STAT_BYTES_UPLOADED, STAT_DOWNLOAD_RATE, STAT_FILES_DOWNLOADED, STAT_FILES_UPLOADED, STAT_UPLOAD_RATE, STRUCT_FILE, STRUCT_RECORD, TYPE_NAMES, WILDCARD
 
Constructor Summary
FtpCmdEpsv()
           
 
Method Summary
protected  java.lang.String createResponseMessage(int protocolIdx, java.lang.String ip, int port)
          Returns the reponse string encoding ip address, port and protocol type.
 java.lang.String getHelp()
          Returns a short help text for the command.
protected  int getPreferredProtocol()
          Returns the preferred protocol version (1=IPv4, 2=IPv6, 0=undefined).
 
Methods inherited from class net.sf.hermesftp.cmd.AbstractFtpCmdPasv
execute, isAuthenticationRequired
 
Methods inherited from class net.sf.hermesftp.cmd.AbstractFtpCmd
getAbsPath, getAndResetFileOffset, getArguments, getCtx, getPathArg, getPermission, getToken, handleAsyncCmd, isResponded, msg, msg, msg, msgOut, msgOut, msgOut, out, setArguments, setCtx, setToken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FtpCmdEpsv

public FtpCmdEpsv()
Method Detail

createResponseMessage

protected java.lang.String createResponseMessage(int protocolIdx,
                                                 java.lang.String ip,
                                                 int port)
Returns the reponse string encoding ip address, port and protocol type. Example: 229 Entering Extended Passive Mode (|||6000|).

Specified by:
createResponseMessage in class AbstractFtpCmdPasv
Parameters:
protocolIdx - The protocol index (1=IPv4, 2=IPv6).
ip - The address.
port - The port.
Returns:
The string encoding the connection data in an appropriate format.

getHelp

public java.lang.String getHelp()
Returns a short help text for the command.

Returns:
The help text.

getPreferredProtocol

protected int getPreferredProtocol()
Returns the preferred protocol version (1=IPv4, 2=IPv6, 0=undefined).

Specified by:
getPreferredProtocol in class AbstractFtpCmdPasv
Returns:
The protocol version.


Copyright © 2005-2007 Lars Behnke. All Rights Reserved.