/src/PcapPlusPlus/Packet++/header/LLCLayer.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef PACKETPP_LLC_LAYER |
2 | | #define PACKETPP_LLC_LAYER |
3 | | |
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 | | * @struct llc_header |
16 | | * Logical Link Control (LLC) header |
17 | | */ |
18 | | #pragma pack(push, 1) |
19 | | struct llc_header |
20 | | { |
21 | | /// Destination Service Access Point |
22 | | uint8_t dsap, |
23 | | /// Source Service Access Point |
24 | | ssap, |
25 | | /// Control Field |
26 | | control; |
27 | | }; |
28 | | #pragma pack(pop) |
29 | | |
30 | | /** |
31 | | * @class LLCLayer |
32 | | * Represents Logical Link Control layer messages |
33 | | */ |
34 | | class LLCLayer : public Layer |
35 | | { |
36 | | public: |
37 | | |
38 | | /** |
39 | | * A constructor that creates the layer from an existing packet raw data |
40 | | * @param[in] data A pointer to the raw data (will be casted to llc_header) |
41 | | * @param[in] dataLen Size of the data in bytes |
42 | | * @param[in] prevLayer A pointer to the previous layer |
43 | | * @param[in] packet A pointer to the Packet instance where layer will be stored in |
44 | | */ |
45 | 5.29k | LLCLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = LLC; } |
46 | | |
47 | | /** |
48 | | * A constructor that creates the LLC layer from provided values |
49 | | * @param[in] dsap Destination Service Access Point |
50 | | * @param[in] ssap Source Service Access Point |
51 | | * @param[in] control Control Field |
52 | | */ |
53 | | LLCLayer(uint8_t dsap, uint8_t ssap, uint8_t control); |
54 | | |
55 | | /** |
56 | | * Get a pointer to Logical Link Control (LLC) layer header |
57 | | * @return Pointer to LLC header |
58 | | */ |
59 | 5.05k | inline llc_header *getLlcHeader() const { return (llc_header*)m_Data; }; |
60 | | |
61 | | // overridden methods |
62 | | |
63 | | /// Parses the next layer. Currently only STP supported as next layer |
64 | | void parseNextLayer(); |
65 | | |
66 | | /// Does nothing for this layer |
67 | 0 | void computeCalculateFields() {} |
68 | | |
69 | | /** |
70 | | * @return Get the size of the LLC header |
71 | | */ |
72 | 0 | size_t getHeaderLen() const { return sizeof(llc_header); } |
73 | | |
74 | | /** |
75 | | * @return Returns the protocol info as readable string |
76 | | */ |
77 | | std::string toString() const; |
78 | | |
79 | | /** |
80 | | * @return The OSI layer level of LLC (Data Link Layer). |
81 | | */ |
82 | 5.29k | OsiModelLayer getOsiModelLayer() const { return OsiModelDataLinkLayer; } |
83 | | |
84 | | /** |
85 | | * A static method that validates the input data |
86 | | * @param[in] data The pointer to the beginning of a byte stream of an LLC packet |
87 | | * @param[in] dataLen The length of the byte stream |
88 | | * @return True if the data is valid and can represent an LLC packet |
89 | | */ |
90 | | static bool isDataValid(const uint8_t *data, size_t dataLen); |
91 | | }; |
92 | | |
93 | | } // namespace pcpp |
94 | | |
95 | | #endif /* PACKETPP_LLC_LAYER */ |