PcapPlusPlus  23.09
pcpp::FtpResponseLayer Class Reference

#include <FtpLayer.h>

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

Public Types

enum  FtpStatusCode : int {
  FtpStatusCode::UNKNOWN, FtpStatusCode::RESTART_MARKER = 110, FtpStatusCode::SERVICE_READY_IN_MIN = 120, FtpStatusCode::DATA_ALREADY_OPEN_START_TRANSFER = 125,
  FtpStatusCode::FILE_OK = 150, FtpStatusCode::COMMAND_OK = 200, FtpStatusCode::COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS = 202, FtpStatusCode::SYSTEM_STATUS = 211,
  FtpStatusCode::DIR_STATUS = 212, FtpStatusCode::FILE_STATUS = 213, FtpStatusCode::HELP_MESSAGE = 214, FtpStatusCode::NAME_SYSTEM_TYPE = 215,
  FtpStatusCode::SERVICE_READY_FOR_USER = 220, FtpStatusCode::SERVICE_CLOSING_CONTROL = 221, FtpStatusCode::DATA_OPEN_NO_TRANSFER = 225, FtpStatusCode::CLOSING_DATA = 226,
  FtpStatusCode::ENTERING_PASSIVE = 227, FtpStatusCode::ENTERING_EXTENDED_PASSIVE = 229, FtpStatusCode::USER_LOG_IN_PROCEED = 230, FtpStatusCode::USER_LOG_IN_AUTHORIZED = 232,
  FtpStatusCode::SEC_DATA_EXCHANGE_COMPLETE = 234, FtpStatusCode::SEC_DATA_EXCHANGE_COMPLETE_SUCCESS = 235, FtpStatusCode::REQ_FILE_OK_COMPLETE = 250, FtpStatusCode::PATHNAME_CREATED = 257,
  FtpStatusCode::USER_OK_NEED_PASSWORD = 331, FtpStatusCode::NEED_ACCOUNT = 332, FtpStatusCode::REQ_SEC_MECHANISM_OK = 334, FtpStatusCode::SEC_IS_ACCEPTABLE = 335,
  FtpStatusCode::USER_OK_NEED_PASS_CHALLENGE = 336, FtpStatusCode::FILE_PENDING_ACTION = 350, FtpStatusCode::SERVICE_NOT_AVAILABLE = 421, FtpStatusCode::CANT_OPEN_DATA_CONNECTION = 425,
  FtpStatusCode::CONNECTION_CLOSED = 426, FtpStatusCode::NEED_UNAVAILABLE_RESOURCE_TO_SEC = 431, FtpStatusCode::REQ_FILE_ACTION_NOT_TAKEN = 450, FtpStatusCode::REQ_ACTION_ABORTED = 451,
  FtpStatusCode::REQ_ACTION_NOT_TAKEN = 452, FtpStatusCode::SYNTAX_ERROR_COMMAND_UNRECOGNIZED = 500, FtpStatusCode::SYNTAX_ERROR_PARAMETER_OR_ARGUMENT = 501, FtpStatusCode::COMMAND_NOT_IMPLEMENTED = 502,
  FtpStatusCode::BAD_SEQUENCE_COMMANDS = 503, FtpStatusCode::COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER = 504, FtpStatusCode::NETWORK_PROTOCOL_NOT_SUPPORTED = 522, FtpStatusCode::NOT_LOGGED_IN = 530,
  FtpStatusCode::NEED_ACCOUNT_FOR_STORE_FILE = 532, FtpStatusCode::COMMAND_PROTECTION_DENIED = 533, FtpStatusCode::REQUEST_DENIED = 534, FtpStatusCode::FAILED_SEC_CHECK = 535,
  FtpStatusCode::REQ_PROT_LEVEL_NOT_SUPPORTED = 536, FtpStatusCode::COMMAND_PROTECTION_LEVEL_NOT_SUPPORTED = 537, FtpStatusCode::FILE_UNAVAILABLE = 550, FtpStatusCode::PAGE_TYPE_UNKNOWN = 551,
  FtpStatusCode::EXCEED_STORAGE_ALLOCATION = 552, FtpStatusCode::FILENAME_NOT_ALLOWED = 553, FtpStatusCode::INTEGRITY_PROTECTED = 631, FtpStatusCode::CONFIDENTIALITY_AND_INTEGRITY_PROTECTED = 632,
  FtpStatusCode::CONFIDENTIALITY_PROTECTED = 633
}
 

Public Member Functions

 FtpResponseLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 FtpResponseLayer (const FtpStatusCode &code, const std::string &option="")
 
bool setStatusCode (FtpStatusCode code)
 
FtpStatusCode getStatusCode () const
 
std::string getStatusCodeString () const
 
bool setStatusOption (const std::string &value)
 
std::string getStatusOption (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 getStatusCodeAsString (FtpStatusCode 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 response messages of FTP Layer

Member Enumeration Documentation

◆ FtpStatusCode

Enum for FTP response codes

Enumerator
UNKNOWN 

Unknown status code.

RESTART_MARKER 

Restart marker reply.

SERVICE_READY_IN_MIN 

Service ready in nnn minutes.

DATA_ALREADY_OPEN_START_TRANSFER 

Data connection already open; transfer starting.

FILE_OK 

File status okay; about to open data connection.

COMMAND_OK 

Command okay.

COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS 

Command not implemented, superfluous at this site.

SYSTEM_STATUS 

System status, or system help reply.

DIR_STATUS 

Directory status.

FILE_STATUS 

File status.

HELP_MESSAGE 

Help message.

NAME_SYSTEM_TYPE 

NAME system type.

SERVICE_READY_FOR_USER 

Service ready for new user.

SERVICE_CLOSING_CONTROL 

Service closing control connection.

DATA_OPEN_NO_TRANSFER 

Data connection open; no transfer in progress.

CLOSING_DATA 

Closing data connection.

ENTERING_PASSIVE 

Entering Passive Mode.

ENTERING_EXTENDED_PASSIVE 

Entering Extended Passive Mode.

USER_LOG_IN_PROCEED 

User logged in, proceed.

USER_LOG_IN_AUTHORIZED 

User logged in, authorized by security data exchange.

SEC_DATA_EXCHANGE_COMPLETE 

Security data exchange complete.

SEC_DATA_EXCHANGE_COMPLETE_SUCCESS 

Security data exchange completed successfully.

REQ_FILE_OK_COMPLETE 

Requested file action okay, completed.

PATHNAME_CREATED 

PATHNAME created.

USER_OK_NEED_PASSWORD 

User name okay, need password.

NEED_ACCOUNT 

Need account for login.

REQ_SEC_MECHANISM_OK 

Requested security mechanism is ok.

SEC_IS_ACCEPTABLE 

Security data is acceptable, more is required.

USER_OK_NEED_PASS_CHALLENGE 

Username okay, need password. Challenge is ...

FILE_PENDING_ACTION 

Requested file action pending further information.

SERVICE_NOT_AVAILABLE 

Service not available, closing control connection.

CANT_OPEN_DATA_CONNECTION 

Can't open data connection.

CONNECTION_CLOSED 

Connection closed; transfer aborted.

NEED_UNAVAILABLE_RESOURCE_TO_SEC 

Need some unavailable resource to process security.

REQ_FILE_ACTION_NOT_TAKEN 

Requested file action not taken.

REQ_ACTION_ABORTED 

Requested action aborted: local error in processing.

REQ_ACTION_NOT_TAKEN 

Requested action not taken. Insufficient storage space in system.

SYNTAX_ERROR_COMMAND_UNRECOGNIZED 

Syntax error, command unrecognized.

SYNTAX_ERROR_PARAMETER_OR_ARGUMENT 

Syntax error in parameters or arguments.

COMMAND_NOT_IMPLEMENTED 

Command not implemented.

BAD_SEQUENCE_COMMANDS 

Bad sequence of commands.

COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER 

Command not implemented for that parameter.

NETWORK_PROTOCOL_NOT_SUPPORTED 

Network protocol not supported.

NOT_LOGGED_IN 

Not logged in.

NEED_ACCOUNT_FOR_STORE_FILE 

Need account for storing files.

COMMAND_PROTECTION_DENIED 

Command protection level denied for policy reasons.

REQUEST_DENIED 

Request denied for policy reasons.

FAILED_SEC_CHECK 

Failed security check (hash, sequence, etc)

REQ_PROT_LEVEL_NOT_SUPPORTED 

Requested PROT level not supported by mechanism.

COMMAND_PROTECTION_LEVEL_NOT_SUPPORTED 

Command protection level not supported by security mechanism.

FILE_UNAVAILABLE 

Requested action not taken: File unavailable.

PAGE_TYPE_UNKNOWN 

Requested action aborted: page type unknown.

EXCEED_STORAGE_ALLOCATION 

Requested file action aborted: Exceeded storage allocation.

FILENAME_NOT_ALLOWED 

Requested action not taken: File name not allowed.

INTEGRITY_PROTECTED 

Integrity protected reply.

CONFIDENTIALITY_AND_INTEGRITY_PROTECTED 

Confidentiality and integrity protected reply.

CONFIDENTIALITY_PROTECTED 

Confidentiality protected reply.

Constructor & Destructor Documentation

◆ FtpResponseLayer() [1/2]

pcpp::FtpResponseLayer::FtpResponseLayer ( 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

◆ FtpResponseLayer() [2/2]

pcpp::FtpResponseLayer::FtpResponseLayer ( const FtpStatusCode code,
const std::string &  option = "" 
)
inlineexplicit

A constructor that creates layer with provided input values

Parameters
[in]codeStatus code
[in]optionArgument of the status code

Member Function Documentation

◆ getStatusCode()

FtpStatusCode pcpp::FtpResponseLayer::getStatusCode ( ) const

Get the status code of response message

Returns
FtpStatusCode Value of the status code

◆ getStatusCodeAsString()

static std::string pcpp::FtpResponseLayer::getStatusCodeAsString ( FtpStatusCode  code)
static

Convert the status code to readable string

Parameters
[in]codeStatus code to convert
Returns
std::string Returns the status info as readable string

◆ getStatusCodeString()

std::string pcpp::FtpResponseLayer::getStatusCodeString ( ) const

Get the status code of response message as string

Returns
std::string Value of the status code as string

◆ getStatusOption()

std::string pcpp::FtpResponseLayer::getStatusOption ( bool  removeEscapeCharacters = true) const

Get the argument of response message

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

◆ setStatusCode()

bool pcpp::FtpResponseLayer::setStatusCode ( FtpStatusCode  code)

Set the status code of response message

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

◆ setStatusOption()

bool pcpp::FtpResponseLayer::setStatusOption ( const std::string &  value)

Set the argument of response message

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

◆ toString()

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

Implements pcpp::Layer.