PcapPlusPlus  22.11
pcpp::FtpRequestLayer Class Reference

#include <FtpLayer.h>

Inheritance diagram for pcpp::FtpRequestLayer:
pcpp::FtpLayer pcpp::SingleCommandTextProtocol pcpp::Layer pcpp::IDataContainer

Public Types

enum  FtpCommand : int {
  FtpCommand::UNK, FtpCommand::ABOR = ('A') | ('B' << 8) | ('O' << 16) | ('R' << 24), FtpCommand::ACCT = ('A') | ('C' << 8) | ('C' << 16) | ('T' << 24), FtpCommand::ADAT = ('A') | ('D' << 8) | ('A' << 16) | ('T' << 24),
  FtpCommand::ALLO = ('A') | ('L' << 8) | ('L' << 16) | ('O' << 24), FtpCommand::APPE = ('A') | ('P' << 8) | ('P' << 16) | ('E' << 24), FtpCommand::AUTH = ('A') | ('U' << 8) | ('T' << 16) | ('H' << 24), FtpCommand::AVBL = ('A') | ('V' << 8) | ('B' << 16) | ('L' << 24),
  FtpCommand::CCC = ('C') | ('C' << 8) | ('C' << 16), FtpCommand::CDUP = ('C') | ('D' << 8) | ('U' << 16) | ('P' << 24), FtpCommand::CONF = ('C') | ('O' << 8) | ('N' << 16) | ('F' << 24), FtpCommand::CSID = ('C') | ('S' << 8) | ('I' << 16) | ('D' << 24),
  FtpCommand::CWD = ('C') | ('W' << 8) | ('D' << 16), FtpCommand::DELE = ('D') | ('E' << 8) | ('L' << 16) | ('E' << 24), FtpCommand::DSIZ = ('D') | ('S' << 8) | ('I' << 16) | ('Z' << 24), FtpCommand::ENC = ('E') | ('N' << 8) | ('C' << 16),
  FtpCommand::EPRT = ('E') | ('P' << 8) | ('R' << 16) | ('T' << 24), FtpCommand::EPSV = ('E') | ('P' << 8) | ('S' << 16) | ('V' << 24), FtpCommand::FEAT = ('F') | ('E' << 8) | ('A' << 16) | ('T' << 24), FtpCommand::HELP = ('H') | ('E' << 8) | ('L' << 16) | ('P' << 24),
  FtpCommand::HOST = ('H') | ('O' << 8) | ('S' << 16) | ('T' << 24), FtpCommand::LANG = ('L') | ('A' << 8) | ('N' << 16) | ('G' << 24), FtpCommand::LIST = ('L') | ('I' << 8) | ('S' << 16) | ('T' << 24), FtpCommand::LPRT = ('L') | ('P' << 8) | ('R' << 16) | ('T' << 24),
  FtpCommand::LPSV = ('L') | ('P' << 8) | ('S' << 16) | ('V' << 24), FtpCommand::MDTM = ('M') | ('D' << 8) | ('T' << 16) | ('M' << 24), FtpCommand::MFCT = ('M') | ('F' << 8) | ('C' << 16) | ('T' << 24), FtpCommand::MFF = ('M') | ('F' << 8) | ('F' << 16),
  FtpCommand::MFMT = ('M') | ('F' << 8) | ('M' << 16) | ('T' << 24), FtpCommand::MIC = ('M') | ('I' << 8) | ('C' << 16), FtpCommand::MKD = ('M') | ('K' << 8) | ('D' << 16), FtpCommand::MLSD = ('M') | ('L' << 8) | ('S' << 16) | ('D' << 24),
  FtpCommand::MLST = ('M') | ('L' << 8) | ('S' << 16) | ('T' << 24), FtpCommand::MODE = ('M') | ('O' << 8) | ('D' << 16) | ('E' << 24), FtpCommand::NLST = ('N') | ('L' << 8) | ('S' << 16) | ('T' << 24), FtpCommand::NOOP = ('N') | ('O' << 8) | ('O' << 16) | ('P' << 24),
  FtpCommand::OPTS = ('O') | ('P' << 8) | ('T' << 16) | ('S' << 24), FtpCommand::PASS = ('P') | ('A' << 8) | ('S' << 16) | ('S' << 24), FtpCommand::PASV = ('P') | ('A' << 8) | ('S' << 16) | ('V' << 24), FtpCommand::PBSZ = ('P') | ('B' << 8) | ('S' << 16) | ('Z' << 24),
  FtpCommand::PORT = ('P') | ('O' << 8) | ('R' << 16) | ('T' << 24), FtpCommand::PROT = ('P') | ('R' << 8) | ('O' << 16) | ('T' << 24), FtpCommand::PWD = ('P') | ('W' << 8) | ('D' << 16), FtpCommand::QUIT = ('Q') | ('U' << 8) | ('I' << 16) | ('T' << 24),
  FtpCommand::REIN = ('R') | ('E' << 8) | ('I' << 16) | ('N' << 24), FtpCommand::REST = ('R') | ('E' << 8) | ('S' << 16) | ('T' << 24), FtpCommand::RETR = ('R') | ('E' << 8) | ('T' << 16) | ('R' << 24), FtpCommand::RMD = ('R') | ('M' << 8) | ('D' << 16),
  FtpCommand::RMDA = ('R') | ('M' << 8) | ('D' << 16) | ('A' << 24), FtpCommand::RNFR = ('R') | ('N' << 8) | ('F' << 16) | ('R' << 24), FtpCommand::RNTO = ('R') | ('N' << 8) | ('T' << 16) | ('O' << 24), FtpCommand::SITE = ('S') | ('I' << 8) | ('T' << 16) | ('E' << 24),
  FtpCommand::SIZE = ('S') | ('I' << 8) | ('Z' << 16) | ('E' << 24), FtpCommand::SMNT = ('S') | ('M' << 8) | ('N' << 16) | ('T' << 24), FtpCommand::SPSV = ('S') | ('P' << 8) | ('S' << 16) | ('V' << 24), FtpCommand::STAT = ('S') | ('T' << 8) | ('A' << 16) | ('T' << 24),
  FtpCommand::STOR = ('S') | ('T' << 8) | ('O' << 16) | ('R' << 24), FtpCommand::STOU = ('S') | ('T' << 8) | ('O' << 16) | ('U' << 24), FtpCommand::STRU = ('S') | ('T' << 8) | ('R' << 16) | ('U' << 24), FtpCommand::SYST = ('S') | ('Y' << 8) | ('S' << 16) | ('T' << 24),
  FtpCommand::THMB = ('T') | ('H' << 8) | ('M' << 16) | ('B' << 24), FtpCommand::TYPE = ('T') | ('Y' << 8) | ('P' << 16) | ('E' << 24), FtpCommand::USER = ('U') | ('S' << 8) | ('E' << 16) | ('R' << 24), FtpCommand::XCUP = ('X') | ('C' << 8) | ('U' << 16) | ('P' << 24),
  FtpCommand::XMKD = ('X') | ('M' << 8) | ('K' << 16) | ('D' << 24), FtpCommand::XPWD = ('X') | ('P' << 8) | ('W' << 16) | ('D' << 24) , FtpCommand::XRMD = ('X') | ('R' << 8) | ('M' << 16) | ('D' << 24) , FtpCommand::XSEM = ('X') | ('S' << 8) | ('E' << 16) | ('M' << 24),
  FtpCommand::XSEN = ('X') | ('S' << 8) | ('E' << 16) | ('N' << 24)
}
 

Public Member Functions

 FtpRequestLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 FtpRequestLayer (const FtpCommand &command, const std::string &option="")
 
bool setCommand (FtpCommand code)
 
FtpCommand getCommand () const
 
std::string getCommandString () const
 
bool setCommandOption (const std::string &value)
 
std::string getCommandOption (bool removeEscapeCharacters=true) const
 
std::string toString () const
 
- Public Member Functions inherited from pcpp::FtpLayer
void parseNextLayer ()
 FTP is the always last so does nothing for this layer.
 
size_t getHeaderLen () const
 
void computeCalculateFields ()
 Does nothing for this layer.
 
OsiModelLayer getOsiModelLayer () const
 
- Public Member Functions inherited from pcpp::SingleCommandTextProtocol
bool isMultiLine () const
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer () const
 
LayergetPrevLayer () const
 
ProtocolType getProtocol () const
 
uint8_t * getData () const
 
size_t getDataLen () const
 
uint8_t * getLayerPayload () const
 
size_t getLayerPayloadSize () const
 
bool isAllocatedToPacket () const
 
void copyData (uint8_t *toArr) const
 
uint8_t * getDataPtr (size_t offset=0) const
 

Static Public Member Functions

static std::string getCommandInfo (FtpCommand code)
 
static std::string getCommandAsString (FtpCommand code)
 
- Static Public Member Functions inherited from pcpp::FtpLayer
static bool isFtpPort (uint16_t port)
 
- Static Public Member Functions inherited from pcpp::SingleCommandTextProtocol
static bool isDataValid (const uint8_t *data, size_t dataSize)
 

Detailed Description

Class for representing the request messages of FTP Layer

Member Enumeration Documentation

◆ FtpCommand

Enum for FTP command codes

Enumerator
UNK 

Unknown command.

ABOR 

Abort an active file transfer.

ACCT 

Account information.

ADAT 

Authentication/Security Data.

ALLO 

Allocate sufficient disk space to receive a file.

APPE 

Append (with create)

AUTH 

Authentication/Security Mechanism.

AVBL 

Get the available space.

CCC 

Clear Command Channel.

CDUP 

Change to Parent Directory.

CONF 

Confidentiality Protection Command.

CSID 

Client / Server Identification.

CWD 

Change working directory.

DELE 

Delete file.

DSIZ 

Get the directory size.

ENC 

Privacy Protected Channel.

EPRT 

Specifies an extended address and port to which the server should connect.

EPSV 

Enter extended passive mode.

FEAT 

Get the feature list implemented by the server.

HELP 

Returns usage documentation on a command if specified, else a general help document is returned.

HOST 

Identify desired virtual host on server, by name.

LANG 

Language Negotiation.

LIST 

Returns information of a file or directory if specified, else information of the current working directory is returned.

LPRT 

Specifies a long address and port to which the server should connect.

LPSV 

Enter long passive mode.

MDTM 

Return the last-modified time of a specified file.

MFCT 

Modify the creation time of a file.

MFF 

Modify fact (the last modification time, creation time, UNIX group/owner/mode of a file).

MFMT 

Modify the last modification time of a file.

MIC 

Integrity Protected Command.

MKD 

Make directory.

MLSD 

Lists the contents of a directory in a standardized machine-readable format.

MLST 

Provides data about exactly the object named on its command line in a standardized machine-readable format.

MODE 

Sets the transfer mode (Stream, Block, or Compressed).

NLST 

Returns a list of file names in a specified directory.

NOOP 

No operation (dummy packet; used mostly on keepalives).

OPTS 

Select options for a feature (for example OPTS UTF8 ON).

PASS 

Authentication password.

PASV 

Enter passive mode.

PBSZ 

Protection Buffer Size.

PORT 

Specifies an address and port to which the server should connect.

PROT 

Data Channel Protection Level.

PWD 

Print working directory. Returns the current directory of the host.

QUIT 

Disconnect.

REIN 

Re initializes the connection.

REST 

Restart transfer from the specified point.

RETR 

Retrieve a copy of the file.

RMD 

Remove a directory.

RMDA 

Remove a directory tree.

RNFR 

Rename from.

RNTO 

Rename to.

SITE 

Sends site specific commands to remote server (like SITE IDLE 60 or SITE UMASK 002). Inspect SITE HELP output for complete list of supported commands.

SIZE 

Return the size of a file.

SMNT 

Mount file structure.

SPSV 

Use single port passive mode (only one TCP port number for both control connections and passive-mode data connections)

STAT 

Returns information on the server status, including the status of the current connection.

STOR 

Accept the data and to store the data as a file at the server site.

STOU 

Store file uniquely.

STRU 

Set file transfer structure.

SYST 

Return system type.

THMB 

Get a thumbnail of a remote image file.

TYPE 

Sets the transfer mode (ASCII/Binary).

USER 

Authentication username.

XCUP 

Change to the parent of the current working directory.

XMKD 

Make a directory.

XPWD 

Print the current working directory.

XRMD 

Remove the directory.

XSEM 

Send, mail if cannot.

XSEN 

Send to terminal.

Constructor & Destructor Documentation

◆ FtpRequestLayer() [1/2]

pcpp::FtpRequestLayer::FtpRequestLayer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 
)
inline

A constructor that creates the layer from an existing packet raw data

Parameters
[in]dataA pointer to the raw data
[in]dataLenSize of the data in bytes
[in]prevLayerA pointer to the previous layer
[in]packetA pointer to the Packet instance where layer will be stored in

◆ FtpRequestLayer() [2/2]

pcpp::FtpRequestLayer::FtpRequestLayer ( const FtpCommand command,
const std::string &  option = "" 
)
inline

A constructor that creates layer with provided input values

Parameters
[in]commandFTP command
[in]optionArgument of the command

Member Function Documentation

◆ getCommand()

FtpCommand pcpp::FtpRequestLayer::getCommand ( ) const

Get the command of request message

Returns
FtpCommand Value of the command

◆ getCommandAsString()

static std::string pcpp::FtpRequestLayer::getCommandAsString ( FtpCommand  code)
static

Convert the command to readable string

Parameters
[in]codeCommand code to convert
Returns
std::string Returns the command as readable string

◆ getCommandInfo()

static std::string pcpp::FtpRequestLayer::getCommandInfo ( FtpCommand  code)
static

Convert the command info to readable string

Parameters
[in]codeCommand code to convert
Returns
std::string Returns the command info as readable string

◆ getCommandOption()

std::string pcpp::FtpRequestLayer::getCommandOption ( bool  removeEscapeCharacters = true) const

Get the command argument of request message

Parameters
[in]removeEscapeCharactersWhether non-alphanumerical characters should be removed or not
Returns
std::string Value of command argument

◆ getCommandString()

std::string pcpp::FtpRequestLayer::getCommandString ( ) const

Get the command of request message as string

Returns
std::string Value of the command as string

◆ setCommand()

bool pcpp::FtpRequestLayer::setCommand ( FtpCommand  code)

Set the command of request message

Parameters
[in]codeValue to set command
Returns
True if the operation is successful, false otherwise

◆ setCommandOption()

bool pcpp::FtpRequestLayer::setCommandOption ( const std::string &  value)

Set the command argument of request message

Parameters
[in]valueValue to set command argument
Returns
True if the operation is successful, false otherwise

◆ toString()

std::string pcpp::FtpRequestLayer::toString ( ) const
virtual
Returns
Returns the protocol info as readable string

Implements pcpp::Layer.