Coverage Report

Created: 2023-01-17 06:15

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