PcapPlusPlus  Next
pcpp::FtpRequestLayer Class Reference

#include <FtpLayer.h>

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

Public Types

enum class  FtpCommand : int {
  UNK , ABOR = ('A') | ('B' << 8) | ('O' << 16) | ('R' << 24) , ACCT = ('A') | ('C' << 8) | ('C' << 16) | ('T' << 24) , ADAT = ('A') | ('D' << 8) | ('A' << 16) | ('T' << 24) ,
  ALLO = ('A') | ('L' << 8) | ('L' << 16) | ('O' << 24) , APPE = ('A') | ('P' << 8) | ('P' << 16) | ('E' << 24) , AUTH = ('A') | ('U' << 8) | ('T' << 16) | ('H' << 24) , AVBL = ('A') | ('V' << 8) | ('B' << 16) | ('L' << 24) ,
  CCC = ('C') | ('C' << 8) | ('C' << 16) , CDUP = ('C') | ('D' << 8) | ('U' << 16) | ('P' << 24) , CONF = ('C') | ('O' << 8) | ('N' << 16) | ('F' << 24) , CSID = ('C') | ('S' << 8) | ('I' << 16) | ('D' << 24) ,
  CWD = ('C') | ('W' << 8) | ('D' << 16) , DELE = ('D') | ('E' << 8) | ('L' << 16) | ('E' << 24) , DSIZ = ('D') | ('S' << 8) | ('I' << 16) | ('Z' << 24) , ENC = ('E') | ('N' << 8) | ('C' << 16) ,
  EPRT = ('E') | ('P' << 8) | ('R' << 16) | ('T' << 24) , EPSV = ('E') | ('P' << 8) | ('S' << 16) | ('V' << 24) , FEAT = ('F') | ('E' << 8) | ('A' << 16) | ('T' << 24) , HELP = ('H') | ('E' << 8) | ('L' << 16) | ('P' << 24) ,
  HOST = ('H') | ('O' << 8) | ('S' << 16) | ('T' << 24) , LANG = ('L') | ('A' << 8) | ('N' << 16) | ('G' << 24) , LIST = ('L') | ('I' << 8) | ('S' << 16) | ('T' << 24) , LPRT = ('L') | ('P' << 8) | ('R' << 16) | ('T' << 24) ,
  LPSV = ('L') | ('P' << 8) | ('S' << 16) | ('V' << 24) , MDTM = ('M') | ('D' << 8) | ('T' << 16) | ('M' << 24) , MFCT = ('M') | ('F' << 8) | ('C' << 16) | ('T' << 24) , MFF = ('M') | ('F' << 8) | ('F' << 16) ,
  MFMT = ('M') | ('F' << 8) | ('M' << 16) | ('T' << 24) , MIC = ('M') | ('I' << 8) | ('C' << 16) , MKD = ('M') | ('K' << 8) | ('D' << 16) , MLSD = ('M') | ('L' << 8) | ('S' << 16) | ('D' << 24) ,
  MLST = ('M') | ('L' << 8) | ('S' << 16) | ('T' << 24) , MODE = ('M') | ('O' << 8) | ('D' << 16) | ('E' << 24) , NLST = ('N') | ('L' << 8) | ('S' << 16) | ('T' << 24) , NOOP = ('N') | ('O' << 8) | ('O' << 16) | ('P' << 24) ,
  OPTS = ('O') | ('P' << 8) | ('T' << 16) | ('S' << 24) , PASS = ('P') | ('A' << 8) | ('S' << 16) | ('S' << 24) , PASV = ('P') | ('A' << 8) | ('S' << 16) | ('V' << 24) , PBSZ = ('P') | ('B' << 8) | ('S' << 16) | ('Z' << 24) ,
  PORT = ('P') | ('O' << 8) | ('R' << 16) | ('T' << 24) , PROT = ('P') | ('R' << 8) | ('O' << 16) | ('T' << 24) , PWD = ('P') | ('W' << 8) | ('D' << 16) , QUIT = ('Q') | ('U' << 8) | ('I' << 16) | ('T' << 24) ,
  REIN = ('R') | ('E' << 8) | ('I' << 16) | ('N' << 24) , REST = ('R') | ('E' << 8) | ('S' << 16) | ('T' << 24) , RETR = ('R') | ('E' << 8) | ('T' << 16) | ('R' << 24) , RMD = ('R') | ('M' << 8) | ('D' << 16) ,
  RMDA = ('R') | ('M' << 8) | ('D' << 16) | ('A' << 24) , RNFR = ('R') | ('N' << 8) | ('F' << 16) | ('R' << 24) , RNTO = ('R') | ('N' << 8) | ('T' << 16) | ('O' << 24) , SITE = ('S') | ('I' << 8) | ('T' << 16) | ('E' << 24) ,
  SIZE = ('S') | ('I' << 8) | ('Z' << 16) | ('E' << 24) , SMNT = ('S') | ('M' << 8) | ('N' << 16) | ('T' << 24) , SPSV = ('S') | ('P' << 8) | ('S' << 16) | ('V' << 24) , STAT = ('S') | ('T' << 8) | ('A' << 16) | ('T' << 24) ,
  STOR = ('S') | ('T' << 8) | ('O' << 16) | ('R' << 24) , STOU = ('S') | ('T' << 8) | ('O' << 16) | ('U' << 24) , STRU = ('S') | ('T' << 8) | ('R' << 16) | ('U' << 24) , SYST = ('S') | ('Y' << 8) | ('S' << 16) | ('T' << 24) ,
  THMB = ('T') | ('H' << 8) | ('M' << 16) | ('B' << 24) , TYPE = ('T') | ('Y' << 8) | ('P' << 16) | ('E' << 24) , USER = ('U') | ('S' << 8) | ('E' << 16) | ('R' << 24) , XCUP = ('X') | ('C' << 8) | ('U' << 16) | ('P' << 24) ,
  XMKD = ('X') | ('M' << 8) | ('K' << 16) | ('D' << 24) , XPWD = ('X') | ('P' << 8) | ('W' << 16) | ('D' << 24) , XRCP = ('X') | ('R' << 8) | ('C' << 16) | ('P' << 24) , XRMD = ('X') | ('R' << 8) | ('M' << 16) | ('D' << 24) ,
  XRSQ = ('X') | ('R' << 8) | ('S' << 16) | ('Q' << 24) , XSEM = ('X') | ('S' << 8) | ('E' << 16) | ('M' << 24) , 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 override
 
- Public Member Functions inherited from pcpp::FtpLayer
void parseNextLayer () override
 FTP is the always last so does nothing for this layer.
 
size_t getHeaderLen () const override
 
void computeCalculateFields () override
 Does nothing for this layer.
 
OsiModelLayer getOsiModelLayer () const override
 
- Public Member Functions inherited from pcpp::SingleCommandTextProtocol
bool isMultiLine () const
 
- Public Member Functions inherited from pcpp::Layer
 ~Layer () override
 
LayergetNextLayer () const
 
LayergetPrevLayer () const
 
ProtocolType getProtocol () const
 
bool isMemberOfProtocolFamily (ProtocolTypeFamily protocolTypeFamily) 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 override
 

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 bool isFtpDataPort (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 = "" 
)
inlineexplicit

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
overridevirtual
Returns
Returns the protocol info as readable string

Implements pcpp::Layer.