PcapPlusPlus  Next
pcpp::SmtpResponseLayer Class Reference

#include <SmtpLayer.h>

Inheritance diagram for pcpp::SmtpResponseLayer:
pcpp::SmtpLayer pcpp::SingleCommandTextProtocol pcpp::Layer pcpp::IDataContainer

Public Types

enum class  SmtpStatusCode : int {
  SYSTEM_STATUS = 211 , HELP_MESSAGE = 214 , SERVICE_READY = 220 , SERVICE_CLOSE = 221 ,
  AUTH_SUCCESS = 235 , COMPLETED = 250 , WILL_FORWARD = 251 , CANNOT_VERIFY = 252 ,
  AUTH_INPUT = 334 , MAIL_INPUT = 354 , SERVICE_UNAVAILABLE = 421 , PASS_NEEDED = 432 ,
  MAILBOX_UNAVAILABLE_TEMP = 450 , ABORT_LOCAL_ERROR = 451 , INSUFFICIENT_STORAGE = 452 , TEMP_AUTH_FAILED = 454 ,
  PARAM_NOT_ACCOMMODATED = 455 , CMD_NOT_RECOGNIZED = 500 , SYNTAX_ERROR_PARAM = 501 , CMD_NOT_IMPLEMENTED = 502 ,
  CMD_BAD_SEQUENCE = 503 , PARAM_NOT_IMPLEMENTED = 504 , MAIL_NOT_ACCEPTED = 521 , ENCRYPT_NEED = 523 ,
  AUTH_REQUIRED = 530 , AUTH_TOO_WEAK = 534 , AUTH_CRED_INVALID = 535 , ENCRYPT_REQUIRED = 538 ,
  MAILBOX_UNAVAILABLE = 550 , USER_NOT_LOCAL = 551 , EXCEED_STORAGE = 552 , NAME_NOT_ALLOWED = 553 ,
  TRANSACTION_FAIL = 554 , DOMAIN_NOT_ACCEPT = 556
}
 

Public Member Functions

 SmtpResponseLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 SmtpResponseLayer (const SmtpStatusCode &code, const std::string &option="")
 
bool setStatusCode (SmtpStatusCode code)
 
SmtpStatusCode getStatusCode () const
 
std::string getStatusCodeString () const
 
bool setStatusOption (const std::string &value)
 
std::string getStatusOption (bool removeEscapeCharacters=true) const
 
std::string toString () const override
 
- Public Member Functions inherited from pcpp::SmtpLayer
void parseNextLayer () override
 SMTP 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 getStatusCodeAsString (SmtpStatusCode code)
 
- Static Public Member Functions inherited from pcpp::SmtpLayer
static bool isSmtpPort (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 SMTP Layer

Member Enumeration Documentation

◆ SmtpStatusCode

Enum for SMTP response codes

Enumerator
SYSTEM_STATUS 

System status, or system help reply.

HELP_MESSAGE 

Help message.

SERVICE_READY 

<domain> Service ready

SERVICE_CLOSE 

<domain> Service closing transmission channel

AUTH_SUCCESS 

Authentication successful.

COMPLETED 

Requested mail action okay, completed.

WILL_FORWARD 

User not local; will forward to <forward-path>

CANNOT_VERIFY 

Cannot VRFY user, but will accept message and attempt delivery.

AUTH_INPUT 

AUTH input.

MAIL_INPUT 

Start mail input; end with <CRLF>.<CRLF>

SERVICE_UNAVAILABLE 

<domain> Service not available, closing transmission channel

PASS_NEEDED 

A password transition is needed.

MAILBOX_UNAVAILABLE_TEMP 

Requested mail action not taken: mailbox unavailable (mail busy or temporarily blocked)

ABORT_LOCAL_ERROR 

Requested action aborted: local error in processing.

INSUFFICIENT_STORAGE 

Requested action not taken: insufficient system storage.

TEMP_AUTH_FAILED 

Temporary authentication failed.

PARAM_NOT_ACCOMMODATED 

Server unable to accommodate parameters.

CMD_NOT_RECOGNIZED 

Syntax error, command unrecognized.

SYNTAX_ERROR_PARAM 

Syntax error in parameters or arguments.

CMD_NOT_IMPLEMENTED 

Command not implemented.

CMD_BAD_SEQUENCE 

Bad sequence of commands.

PARAM_NOT_IMPLEMENTED 

Command parameter not implemented.

MAIL_NOT_ACCEPTED 

Server does not accept mail.

ENCRYPT_NEED 

Encryption needed.

AUTH_REQUIRED 

Authentication required.

AUTH_TOO_WEAK 

Authentication mechanism is too weak.

AUTH_CRED_INVALID 

Authentication credentials invalid.

ENCRYPT_REQUIRED 

Encryption required for requested authentication mechanism.

MAILBOX_UNAVAILABLE 

Requested action not taken: mailbox unavailable.

USER_NOT_LOCAL 

User not local; please try <forward-path>

EXCEED_STORAGE 

Requested mail action aborted: exceeded storage allocation.

NAME_NOT_ALLOWED 

Requested action not taken: mailbox name not allowed.

TRANSACTION_FAIL 

Transaction failed.

DOMAIN_NOT_ACCEPT 

Domain does not accept mail.

Constructor & Destructor Documentation

◆ SmtpResponseLayer() [1/2]

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

◆ SmtpResponseLayer() [2/2]

pcpp::SmtpResponseLayer::SmtpResponseLayer ( const SmtpStatusCode 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()

SmtpStatusCode pcpp::SmtpResponseLayer::getStatusCode ( ) const

Get the status code of response message

Returns
Value of the status code

◆ getStatusCodeAsString()

static std::string pcpp::SmtpResponseLayer::getStatusCodeAsString ( SmtpStatusCode  code)
static

Convert the status code to readable string

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

◆ getStatusCodeString()

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

Get the status code of response message as string

Returns
Value of the status code as string

◆ getStatusOption()

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

Get the argument of response message

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

◆ setStatusCode()

bool pcpp::SmtpResponseLayer::setStatusCode ( SmtpStatusCode  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::SmtpResponseLayer::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::SmtpResponseLayer::toString ( ) const
overridevirtual
Returns
Returns the protocol info as readable string

Implements pcpp::Layer.