PcapPlusPlus
|
#include <Layer.h>
Public Member Functions | |
virtual | ~Layer () |
Layer * | getNextLayer () |
Layer * | getPrevLayer () |
ProtocolType | getProtocol () |
uint8_t * | getData () |
size_t | getDataLen () |
uint8_t * | getLayerPayload () |
size_t | getLayerPayloadSize () |
bool | isAllocatedToPacket () |
void | copyData (uint8_t *toArr) |
uint8_t * | getDataPtr (size_t offset=0) |
virtual void | parseNextLayer ()=0 |
virtual size_t | getHeaderLen ()=0 |
virtual void | computeCalculateFields ()=0 |
virtual std::string | toString ()=0 |
virtual OsiModelLayer | getOsiModelLayer ()=0 |
Layer is the base class for all protocol layers. Each protocol supported in PcapPlusPlus has a class that inherits Layer. The protocol layer class expose all properties and methods relevant for viewing and editing protocol fields. For example: a pointer to a structured header (e.g tcphdr, iphdr, etc.), protocol header size, payload size, compute fields that can be automatically computed, print protocol data to string, etc. Each protocol instance is obviously part of a protocol stack (which construct a packet). This protocol stack is represented in PcapPlusPlus in a linked list, and each layer is an element in this list. That's why each layer has proprties to the next and previous layer in the protocol stack The Layer class, as a base class, is abstract and the user can't create an instance of it (it has a private constructor) Each layer holds a pointer to the relevant place in the packet. The layer sees all the data from this pointer forward until the end of the packet. Here is an example packet showing this concept:
==================================================== |Eth |IPv4 |TCP |Packet | |Header |Header |Header |Payload | ==================================================== |--------------------------------------------------| EthLayer data |---------------------------------------| IPv4Layer data |---------------------------| TcpLayer data |----------------| PayloadLayer data
|
virtual |
A destructor for this class. Frees the data if it was allocated by the layer constructor (see isAllocatedToPacket() for more info)
|
pure virtual |
Each layer can compute field values automatically using this method. This is an abstract method
Implemented in pcpp::DnsLayer, pcpp::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::IgmpV3ReportLayer, pcpp::SSLApplicationDataLayer, pcpp::SSLAlertLayer, pcpp::PPP_PPTPLayer, pcpp::TcpLayer, pcpp::SSLChangeCipherSpecLayer, pcpp::IgmpV3QueryLayer, pcpp::GREv1Layer, pcpp::SSLHandshakeLayer, pcpp::IgmpV2Layer, pcpp::GREv0Layer, pcpp::IgmpV1Layer, pcpp::TextBasedProtocolMessage, pcpp::IPv6Layer, pcpp::EthLayer, pcpp::ArpLayer, pcpp::VlanLayer, pcpp::VxlanLayer, pcpp::MplsLayer, pcpp::SipLayer, pcpp::SllLayer, pcpp::PPPoELayer, pcpp::UdpLayer, pcpp::NullLoopbackLayer, pcpp::PacketTrailerLayer, and pcpp::PayloadLayer.
void pcpp::Layer::copyData | ( | uint8_t * | toArr | ) |
Copy the raw data of this layer to another array
[out] | toArr | The destination byte array |
|
inline |
|
inline |
|
inlinevirtual |
Get a pointer to the data
[in] | offset | Get a pointer in a certain offset. Default is 0 - get a pointer to start of data |
Implements pcpp::IDataContainer.
|
pure virtual |
Implemented in pcpp::DnsLayer, pcpp::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::IgmpV3ReportLayer, pcpp::PPP_PPTPLayer, pcpp::IgmpV3QueryLayer, pcpp::TcpLayer, pcpp::PPPoEDiscoveryLayer, pcpp::SSLLayer, pcpp::IgmpLayer, pcpp::TextBasedProtocolMessage, pcpp::PPPoESessionLayer, pcpp::GreLayer, pcpp::IPv6Layer, pcpp::EthLayer, pcpp::VlanLayer, pcpp::VxlanLayer, pcpp::ArpLayer, pcpp::MplsLayer, pcpp::SllLayer, pcpp::UdpLayer, pcpp::NullLoopbackLayer, pcpp::PacketTrailerLayer, and pcpp::PayloadLayer.
|
inline |
|
inline |
|
inline |
|
pure virtual |
Implemented in pcpp::DnsLayer, pcpp::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::PPP_PPTPLayer, pcpp::TcpLayer, pcpp::SSLLayer, pcpp::IgmpLayer, pcpp::IPv6Layer, pcpp::GreLayer, pcpp::SdpLayer, pcpp::EthLayer, pcpp::ArpLayer, pcpp::VlanLayer, pcpp::VxlanLayer, pcpp::MplsLayer, pcpp::SllLayer, pcpp::SipLayer, pcpp::PPPoELayer, pcpp::HttpMessage, pcpp::UdpLayer, pcpp::NullLoopbackLayer, pcpp::PacketTrailerLayer, and pcpp::PayloadLayer.
|
inline |
|
inline |
|
inline |
Raw data in layers can come from one of sources:
|
pure virtual |
Each layer is responsible for parsing the next layer
Implemented in pcpp::DnsLayer, pcpp::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::PPP_PPTPLayer, pcpp::TcpLayer, pcpp::PPPoEDiscoveryLayer, pcpp::SSLLayer, pcpp::IgmpLayer, pcpp::TextBasedProtocolMessage, pcpp::PPPoESessionLayer, pcpp::GreLayer, pcpp::IPv6Layer, pcpp::EthLayer, pcpp::VlanLayer, pcpp::VxlanLayer, pcpp::ArpLayer, pcpp::SipLayer, pcpp::MplsLayer, pcpp::SllLayer, pcpp::UdpLayer, pcpp::NullLoopbackLayer, pcpp::PacketTrailerLayer, and pcpp::PayloadLayer.
|
pure virtual |
Implemented in pcpp::DnsLayer, pcpp::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::SSLApplicationDataLayer, pcpp::HttpResponseLayer, pcpp::SipResponseLayer, pcpp::SSLAlertLayer, pcpp::PPP_PPTPLayer, pcpp::TcpLayer, pcpp::SSLChangeCipherSpecLayer, pcpp::PPPoEDiscoveryLayer, pcpp::GREv1Layer, pcpp::SSLHandshakeLayer, pcpp::GREv0Layer, pcpp::IgmpLayer, pcpp::SipRequestLayer, pcpp::HttpRequestLayer, pcpp::IPv6Layer, pcpp::PPPoESessionLayer, pcpp::SdpLayer, pcpp::EthLayer, pcpp::ArpLayer, pcpp::VlanLayer, pcpp::VxlanLayer, pcpp::MplsLayer, pcpp::SllLayer, pcpp::UdpLayer, pcpp::NullLoopbackLayer, pcpp::PacketTrailerLayer, and pcpp::PayloadLayer.