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