/src/PcapPlusPlus/Packet++/header/NullLoopbackLayer.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef PACKETPP_NULL_LOOPBACK_LAYER |
2 | | #define PACKETPP_NULL_LOOPBACK_LAYER |
3 | | |
4 | | /// @file |
5 | | |
6 | | #include "Layer.h" |
7 | | |
8 | | namespace pcpp |
9 | | { |
10 | | |
11 | | /** IPv4 protocol **/ |
12 | 3.45k | #define PCPP_BSD_AF_INET 2 |
13 | | /** XEROX NS protocols */ |
14 | | #define PCPP_BSD_AF_NS 6 |
15 | | /** ISO */ |
16 | | #define PCPP_BSD_AF_ISO 7 |
17 | | /** AppleTalk */ |
18 | | #define PCPP_BSD_AF_APPLETALK 16 |
19 | | /** IPX */ |
20 | | #define PCPP_BSD_AF_IPX 23 |
21 | | /** OpenBSD (and probably NetBSD), BSD/OS IPv6 */ |
22 | 338 | #define PCPP_BSD_AF_INET6_BSD 24 |
23 | | /** FreeBSD IPv6 */ |
24 | 1.11k | #define PCPP_BSD_AF_INET6_FREEBSD 28 |
25 | | /** Darwin IPv6 */ |
26 | 1.67k | #define PCPP_BSD_AF_INET6_DARWIN 30 |
27 | | |
28 | | /** |
29 | | * @class NullLoopbackLayer |
30 | | * Represents a NULL/Loopback layer |
31 | | */ |
32 | | class NullLoopbackLayer : public Layer |
33 | | { |
34 | | public: |
35 | | /** A constructor that creates the layer from an existing packet raw data |
36 | | * @param[in] data A pointer to the raw data |
37 | | * @param[in] dataLen Size of the data in bytes |
38 | | * @param[in] packet A pointer to the Packet instance where layer will be stored in |
39 | | */ |
40 | 13.1k | NullLoopbackLayer(uint8_t* data, size_t dataLen, Packet* packet) : Layer(data, dataLen, NULL, packet) { m_Protocol = NULL_LOOPBACK; } |
41 | | |
42 | | /** |
43 | | * A constructor that allocates a new Null/Loopback header |
44 | | * @param[in] family The family protocol to set |
45 | | */ |
46 | | explicit NullLoopbackLayer(uint32_t family); |
47 | | |
48 | | /** |
49 | | * A destructor for this layer (does nothing) |
50 | | */ |
51 | 0 | ~NullLoopbackLayer() {} |
52 | | |
53 | | /** |
54 | | * @return The protocol family in this layer |
55 | | */ |
56 | | uint32_t getFamily() const; |
57 | | |
58 | | /** |
59 | | * Set a protocol family |
60 | | * @param[in] family The family protocol to set |
61 | | */ |
62 | | void setFamily(uint32_t family); |
63 | | |
64 | | |
65 | | // implement abstract methods |
66 | | |
67 | | /** |
68 | | * Identifies the next layers by family: |
69 | | * - for ::PCPP_BSD_AF_INET the next layer is IPv4Layer |
70 | | * - for ::PCPP_BSD_AF_INET6_BSD, ::PCPP_BSD_AF_INET6_FREEBSD, ::PCPP_BSD_AF_INET6_DARWIN the next layer is IPv6Layer |
71 | | * - for other values the next layer in PayloadLayer (unknown protocol) |
72 | | */ |
73 | | void parseNextLayer(); |
74 | | |
75 | | /** |
76 | | * @return Size of Null/Loopback header = 4B |
77 | | */ |
78 | 0 | size_t getHeaderLen() const { return sizeof(uint32_t); } |
79 | | |
80 | | /** |
81 | | * Does nothing for this layer |
82 | | */ |
83 | 0 | void computeCalculateFields() {} |
84 | | |
85 | | std::string toString() const; |
86 | | |
87 | 13.1k | OsiModelLayer getOsiModelLayer() const { return OsiModelDataLinkLayer; } |
88 | | }; |
89 | | |
90 | | } // namespace pcpp |
91 | | |
92 | | #endif /* PACKETPP_NULL_LOOPBACK_LAYER */ |