1 #ifndef PACKETPP_SMTP_LAYER
2 #define PACKETPP_SMTP_LAYER
20 SmtpLayer(
const std::string& command,
const std::string& option)
29 return port == 25 || port == 587;
65 DATA = (
'D') | (
'A' << 8) | (
'T' << 16) | (
'A' << 24),
67 EHLO = (
'E') | (
'H' << 8) | (
'L' << 16) | (
'O' << 24),
69 EXPN = (
'E') | (
'X' << 8) | (
'P' << 16) | (
'N' << 24),
71 HELO = (
'H') | (
'E' << 8) | (
'L' << 16) | (
'O' << 24),
73 HELP = (
'H') | (
'E' << 8) | (
'L' << 16) | (
'P' << 24),
75 MAIL = (
'M') | (
'A' << 8) | (
'I' << 16) | (
'L' << 24),
77 NOOP = (
'N') | (
'O' << 8) | (
'O' << 16) | (
'P' << 24),
79 QUIT = (
'Q') | (
'U' << 8) | (
'I' << 16) | (
'T' << 24),
81 RCPT = (
'R') | (
'C' << 8) | (
'P' << 16) | (
'T' << 24),
83 RSET = (
'R') | (
'S' << 8) | (
'E' << 16) | (
'T' << 24),
85 VRFY = (
'V') | (
'R' << 8) | (
'F' << 16) | (
'Y' << 24),
87 STARTTLS = ((
'S') | (
'T' << 8) | (
'A' << 16) | (
'R' << 24) |
88 static_cast<uint64_t
>((
'T') | (
'T' << 8) | (
'L' << 16) | (
'S' << 24)) << 32),
90 TURN = (
'T') | (
'U' << 8) | (
'R' << 16) | (
'N' << 24),
92 SEND = (
'S') | (
'E' << 8) | (
'N' << 16) | (
'D' << 24),
94 SOML = (
'S') | (
'O' << 8) | (
'M' << 16) | (
'L' << 24),
96 SAML = (
'S') | (
'A' << 8) | (
'M' << 16) | (
'L' << 24),
98 AUTH = (
'A') | (
'U' << 8) | (
'T' << 16) | (
'H' << 24),
100 ATRN = (
'A') | (
'T' << 8) | (
'R' << 16) | (
'N' << 24),
102 BDAT = (
'B') | (
'D' << 8) | (
'A' << 16) | (
'T' << 24),
104 ETRN = (
'E') | (
'T' << 8) | (
'R' << 16) | (
'N' << 24),
106 XADR = (
'X') | (
'A' << 8) | (
'D' << 16) | (
'R' << 24),
108 XCIR = (
'X') | (
'C' << 8) | (
'I' << 16) | (
'R' << 24),
110 XSTA = (
'X') | (
'S' << 8) | (
'T' << 16) | (
'A' << 24),
112 XGEN = (
'X') | (
'G' << 8) | (
'E' << 16) | (
'N' << 24)
121 :
SmtpLayer(data, dataLen, prevLayer, packet) {};
251 :
SmtpLayer(data, dataLen, prevLayer, packet) {};
257 :
SmtpLayer(std::to_string(int(code)), option) {};
Class for single command text based protocol (FTP, SMTP) messages.
Definition: SingleCommandTextProtocol.h:14
Class for general SMTP message.
Definition: SmtpLayer.h:15
void parseNextLayer() override
SMTP is the always last so does nothing for this layer.
Definition: SmtpLayer.h:35
static bool isSmtpPort(uint16_t port)
Definition: SmtpLayer.h:27
size_t getHeaderLen() const override
Definition: SmtpLayer.h:39
void computeCalculateFields() override
Does nothing for this layer.
Definition: SmtpLayer.h:45
OsiModelLayer getOsiModelLayer() const override
Definition: SmtpLayer.h:49
Class for representing the request messages of SMTP Layer.
Definition: SmtpLayer.h:57
std::string getCommandString() const
SmtpCommand
Enum for SMTP command codes.
Definition: SmtpLayer.h:61
@ STARTTLS
Start TLS handshake.
@ SAML
Send mail to terminal and mailbox.
@ TURN
Reverse the role of sender and receiver.
@ BDAT
Submit mail contents.
@ ETRN
Request to start SMTP queue processing.
@ ATRN
Reverse the role of sender and receiver.
@ SEND
Send mail to terminal.
@ QUIT
Close conversation.
@ EXPN
Expand the mailing list.
@ EHLO
Initiate conversation.
@ XGEN
Release status of whether a compiled configuration and character set are in use.
@ SOML
Send mail to terminal or to mailbox.
@ RCPT
Receiver indication.
@ XADR
Release status of the channel.
@ XSTA
Release status of the number of messages in channel queues.
@ XCIR
Release status of the circuit checking facility.
@ DATA
Starting mail body.
@ AUTH
Authenticate client and server.
@ HELO
Initiate conversation.
static std::string getCommandAsString(SmtpCommand code)
bool setCommand(SmtpCommand code)
std::string toString() const override
SmtpRequestLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: SmtpLayer.h:120
SmtpCommand getCommand() const
static std::string getCommandInfo(SmtpCommand code)
std::string getCommandOption(bool removeEscapeCharacters=true) const
SmtpRequestLayer(const SmtpCommand &command, const std::string &option="")
Definition: SmtpLayer.h:126
bool setCommandOption(const std::string &value)
Class for representing the response messages of SMTP Layer.
Definition: SmtpLayer.h:170
SmtpResponseLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: SmtpLayer.h:250
static std::string getStatusCodeAsString(SmtpStatusCode code)
bool setStatusOption(const std::string &value)
SmtpStatusCode
Enum for SMTP response codes.
Definition: SmtpLayer.h:174
@ NAME_NOT_ALLOWED
Requested action not taken: mailbox name not allowed.
@ PARAM_NOT_ACCOMMODATED
Server unable to accommodate parameters.
@ INSUFFICIENT_STORAGE
Requested action not taken: insufficient system storage.
@ SERVICE_READY
<domain> Service ready
@ HELP_MESSAGE
Help message.
@ ENCRYPT_NEED
Encryption needed.
@ EXCEED_STORAGE
Requested mail action aborted: exceeded storage allocation.
@ SERVICE_UNAVAILABLE
<domain> Service not available, closing transmission channel
@ MAILBOX_UNAVAILABLE_TEMP
Requested mail action not taken: mailbox unavailable (mail busy or temporarily blocked)
@ SERVICE_CLOSE
<domain> Service closing transmission channel
@ ENCRYPT_REQUIRED
Encryption required for requested authentication mechanism.
@ AUTH_CRED_INVALID
Authentication credentials invalid.
@ SYSTEM_STATUS
System status, or system help reply.
@ ABORT_LOCAL_ERROR
Requested action aborted: local error in processing.
@ CMD_BAD_SEQUENCE
Bad sequence of commands.
@ CMD_NOT_IMPLEMENTED
Command not implemented.
@ AUTH_REQUIRED
Authentication required.
@ CMD_NOT_RECOGNIZED
Syntax error, command unrecognized.
@ USER_NOT_LOCAL
User not local; please try <forward-path>
@ COMPLETED
Requested mail action okay, completed.
@ SYNTAX_ERROR_PARAM
Syntax error in parameters or arguments.
@ PASS_NEEDED
A password transition is needed.
@ TRANSACTION_FAIL
Transaction failed.
@ DOMAIN_NOT_ACCEPT
Domain does not accept mail.
@ MAIL_NOT_ACCEPTED
Server does not accept mail.
@ MAILBOX_UNAVAILABLE
Requested action not taken: mailbox unavailable.
@ PARAM_NOT_IMPLEMENTED
Command parameter not implemented.
@ TEMP_AUTH_FAILED
Temporary authentication failed.
@ AUTH_SUCCESS
Authentication successful.
@ MAIL_INPUT
Start mail input; end with <CRLF>.<CRLF>
@ WILL_FORWARD
User not local; will forward to <forward-path>
@ AUTH_TOO_WEAK
Authentication mechanism is too weak.
@ CANNOT_VERIFY
Cannot VRFY user, but will accept message and attempt delivery.
std::string toString() const override
bool setStatusCode(SmtpStatusCode code)
std::string getStatusCodeString() const
std::string getStatusOption(bool removeEscapeCharacters=true) const
SmtpResponseLayer(const SmtpStatusCode &code, const std::string &option="")
Definition: SmtpLayer.h:256
SmtpStatusCode getStatusCode() const
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:225
@ OsiModelApplicationLayer
Application layer (layer 7)
Definition: ProtocolType.h:239
const ProtocolType SMTP
SMTP protocol.
Definition: ProtocolType.h:209