PcapPlusPlus  Next
pcpp::SmtpRequestLayer Class Reference

#include <SmtpLayer.h>

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

Public Types

enum class  SmtpCommand : uint64_t {
  UNK , DATA = ('D') | ('A' << 8) | ('T' << 16) | ('A' << 24) , EHLO = ('E') | ('H' << 8) | ('L' << 16) | ('O' << 24) , EXPN = ('E') | ('X' << 8) | ('P' << 16) | ('N' << 24) ,
  HELO = ('H') | ('E' << 8) | ('L' << 16) | ('O' << 24) , HELP = ('H') | ('E' << 8) | ('L' << 16) | ('P' << 24) , MAIL = ('M') | ('A' << 8) | ('I' << 16) | ('L' << 24) , NOOP = ('N') | ('O' << 8) | ('O' << 16) | ('P' << 24) ,
  QUIT = ('Q') | ('U' << 8) | ('I' << 16) | ('T' << 24) , RCPT = ('R') | ('C' << 8) | ('P' << 16) | ('T' << 24) , RSET = ('R') | ('S' << 8) | ('E' << 16) | ('T' << 24) , VRFY = ('V') | ('R' << 8) | ('F' << 16) | ('Y' << 24) ,
  STARTTLS , TURN = ('T') | ('U' << 8) | ('R' << 16) | ('N' << 24) , SEND = ('S') | ('E' << 8) | ('N' << 16) | ('D' << 24) , SOML = ('S') | ('O' << 8) | ('M' << 16) | ('L' << 24) ,
  SAML = ('S') | ('A' << 8) | ('M' << 16) | ('L' << 24) , AUTH = ('A') | ('U' << 8) | ('T' << 16) | ('H' << 24) , ATRN = ('A') | ('T' << 8) | ('R' << 16) | ('N' << 24) , BDAT = ('B') | ('D' << 8) | ('A' << 16) | ('T' << 24) ,
  ETRN = ('E') | ('T' << 8) | ('R' << 16) | ('N' << 24) , XADR = ('X') | ('A' << 8) | ('D' << 16) | ('R' << 24) , XCIR = ('X') | ('C' << 8) | ('I' << 16) | ('R' << 24) , XSTA = ('X') | ('S' << 8) | ('T' << 16) | ('A' << 24) ,
  XGEN = ('X') | ('G' << 8) | ('E' << 16) | ('N' << 24)
}
 

Public Member Functions

 SmtpRequestLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 SmtpRequestLayer (const SmtpCommand &command, const std::string &option="")
 
bool setCommand (SmtpCommand code)
 
SmtpCommand 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::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 getCommandInfo (SmtpCommand code)
 
static std::string getCommandAsString (SmtpCommand 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 request messages of SMTP Layer

Member Enumeration Documentation

◆ SmtpCommand

enum pcpp::SmtpRequestLayer::SmtpCommand : uint64_t
strong

Enum for SMTP command codes

Enumerator
UNK 

Unknown command.

DATA 

Starting mail body.

EHLO 

Initiate conversation.

EXPN 

Expand the mailing list.

HELO 

Initiate conversation.

HELP 

Ask information.

MAIL 

Sender indication.

NOOP 

No operation.

QUIT 

Close conversation.

RCPT 

Receiver indication.

RSET 

Abort transaction.

VRFY 

Identify user.

STARTTLS 

Start TLS handshake.

TURN 

Reverse the role of sender and receiver.

SEND 

Send mail to terminal.

SOML 

Send mail to terminal or to mailbox.

SAML 

Send mail to terminal and mailbox.

AUTH 

Authenticate client and server.

ATRN 

Reverse the role of sender and receiver.

BDAT 

Submit mail contents.

ETRN 

Request to start SMTP queue processing.

XADR 

Release status of the channel.

XCIR 

Release status of the circuit checking facility.

XSTA 

Release status of the number of messages in channel queues.

XGEN 

Release status of whether a compiled configuration and character set are in use.

Constructor & Destructor Documentation

◆ SmtpRequestLayer() [1/2]

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

◆ SmtpRequestLayer() [2/2]

pcpp::SmtpRequestLayer::SmtpRequestLayer ( const SmtpCommand command,
const std::string &  option = "" 
)
inlineexplicit

A constructor that creates layer with provided input values

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

Member Function Documentation

◆ getCommand()

SmtpCommand pcpp::SmtpRequestLayer::getCommand ( ) const

Get the command of request message

Returns
Value of the command

◆ getCommandAsString()

static std::string pcpp::SmtpRequestLayer::getCommandAsString ( SmtpCommand  code)
static

Convert the command to readable string

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

◆ getCommandInfo()

static std::string pcpp::SmtpRequestLayer::getCommandInfo ( SmtpCommand  code)
static

Convert the command info to readable string

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

◆ getCommandOption()

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

Get the command argument of request message

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

◆ getCommandString()

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

Get the command of request message as string

Returns
Value of the command as string

◆ setCommand()

bool pcpp::SmtpRequestLayer::setCommand ( SmtpCommand  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::SmtpRequestLayer::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::SmtpRequestLayer::toString ( ) const
overridevirtual
Returns
Returns the protocol info as readable string

Implements pcpp::Layer.