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