Line | Count | Source |
1 | #pragma once | |
2 | ||
3 | #include <sstream> | |
4 | #include "Layer.h" | |
5 | ||
6 | /// @file | |
7 | ||
8 | /// @namespace pcpp | |
9 | /// @brief The main namespace for the PcapPlusPlus lib | |
10 | namespace pcpp | |
11 | { | |
12 | /// Class for single command text based protocol (FTP, SMTP) messages | |
13 | class SingleCommandTextProtocol : public Layer | |
14 | { | |
15 | private: | |
16 | size_t getArgumentFieldOffset() const; | |
17 | void setDelimiter(bool hyphen); | |
18 | bool hyphenRequired(const std::string& value); | |
19 | ||
20 | protected: | |
21 | SingleCommandTextProtocol(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, | |
22 | ProtocolType protocol) | |
23 | 0 | : Layer(data, dataLen, prevLayer, packet, protocol) {}; |
24 | ||
25 | SingleCommandTextProtocol(const std::string& command, const std::string& option, ProtocolType protocol); | |
26 | ||
27 | bool setCommandInternal(std::string value); | |
28 | bool setCommandOptionInternal(std::string value); | |
29 | ||
30 | std::string getCommandInternal() const; | |
31 | std::string getCommandOptionInternal() const; | |
32 | ||
33 | public: | |
34 | /// Checks if the current message is a multi-line reply. Multi-line messages are indicated with a Hyphen (-) | |
35 | /// immediately after reply code. | |
36 | /// @return true If this is a multi-line reply | |
37 | /// @return false Otherwise | |
38 | bool isMultiLine() const; | |
39 | ||
40 | /// A static method that takes a byte array and detects whether it is a single command text based message. | |
41 | /// All single command text based message terminated with single "\r\n". | |
42 | /// @param[in] data A byte array | |
43 | /// @param[in] dataSize The byte array size (in bytes) | |
44 | /// @return True if the data is identified as single command text based message | |
45 | static bool isDataValid(const uint8_t* data, size_t dataSize); | |
46 | }; | |
47 | } // namespace pcpp |