PcapPlusPlus
21.05
|
#include <Layer.h>
Public Member Functions | |
virtual | ~Layer () |
Layer * | getNextLayer () const |
Layer * | getPrevLayer () const |
ProtocolType | getProtocol () const |
uint8_t * | getData () const |
size_t | getDataLen () const |
uint8_t * | getLayerPayload () const |
size_t | getLayerPayloadSize () const |
bool | isAllocatedToPacket () const |
void | copyData (uint8_t *toArr) const |
uint8_t * | getDataPtr (size_t offset=0) const |
virtual void | parseNextLayer ()=0 |
virtual size_t | getHeaderLen () const =0 |
virtual void | computeCalculateFields ()=0 |
virtual std::string | toString () const =0 |
virtual OsiModelLayer | getOsiModelLayer () const =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::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::DnsOverTcpLayer, pcpp::IgmpV3ReportLayer, pcpp::SSLApplicationDataLayer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::SSLAlertLayer, pcpp::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::IgmpV3QueryLayer, pcpp::SSLChangeCipherSpecLayer, pcpp::GREv1Layer, pcpp::SSLHandshakeLayer, pcpp::RadiusLayer, pcpp::IgmpV2Layer, pcpp::GREv0Layer, pcpp::IgmpV1Layer, pcpp::TextBasedProtocolMessage, pcpp::IPv6Layer, pcpp::ESPLayer, pcpp::EthLayer, pcpp::VxlanLayer, pcpp::ArpLayer, pcpp::VlanLayer, pcpp::BgpLayer, pcpp::AuthenticationHeaderLayer, pcpp::MplsLayer, pcpp::SipLayer, pcpp::EthDot3Layer, pcpp::SSHLayer, pcpp::SllLayer, pcpp::PPPoELayer, pcpp::UdpLayer, pcpp::NullLoopbackLayer, pcpp::PayloadLayer, and pcpp::PacketTrailerLayer.
void pcpp::Layer::copyData | ( | uint8_t * | toArr | ) | const |
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::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::IgmpV3ReportLayer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::SSHEncryptedMessage, pcpp::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::IgmpV3QueryLayer, pcpp::PPPoEDiscoveryLayer, pcpp::RadiusLayer, pcpp::SSHHandshakeMessage, pcpp::SSLLayer, pcpp::TextBasedProtocolMessage, pcpp::IgmpLayer, pcpp::IPv6Layer, pcpp::ESPLayer, pcpp::PPPoESessionLayer, pcpp::GreLayer, pcpp::SSHIdentificationMessage, pcpp::EthLayer, pcpp::VxlanLayer, pcpp::ArpLayer, pcpp::VlanLayer, pcpp::MplsLayer, pcpp::AuthenticationHeaderLayer, pcpp::EthDot3Layer, pcpp::BgpLayer, pcpp::SllLayer, pcpp::UdpLayer, pcpp::NullLoopbackLayer, pcpp::PayloadLayer, and pcpp::PacketTrailerLayer.
|
inline |
|
inline |
|
inline |
|
pure virtual |
Implemented in pcpp::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::RadiusLayer, pcpp::SSLLayer, pcpp::IgmpLayer, pcpp::IPv6Layer, pcpp::ESPLayer, pcpp::GreLayer, pcpp::SdpLayer, pcpp::EthLayer, pcpp::VxlanLayer, pcpp::ArpLayer, pcpp::VlanLayer, pcpp::AuthenticationHeaderLayer, pcpp::MplsLayer, pcpp::EthDot3Layer, pcpp::BgpLayer, pcpp::SSHLayer, pcpp::SllLayer, pcpp::SipLayer, pcpp::UdpLayer, pcpp::PPPoELayer, pcpp::HttpMessage, pcpp::PayloadLayer, pcpp::NullLoopbackLayer, and pcpp::PacketTrailerLayer.
|
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::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::PPPoEDiscoveryLayer, pcpp::RadiusLayer, pcpp::SSLLayer, pcpp::TextBasedProtocolMessage, pcpp::IgmpLayer, pcpp::IPv6Layer, pcpp::ESPLayer, pcpp::PPPoESessionLayer, pcpp::GreLayer, pcpp::EthLayer, pcpp::VxlanLayer, pcpp::ArpLayer, pcpp::VlanLayer, pcpp::AuthenticationHeaderLayer, pcpp::SipLayer, pcpp::BgpLayer, pcpp::MplsLayer, pcpp::SSHLayer, pcpp::EthDot3Layer, pcpp::SllLayer, pcpp::UdpLayer, pcpp::NullLoopbackLayer, pcpp::PayloadLayer, and pcpp::PacketTrailerLayer.
|
pure virtual |
Implemented in pcpp::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::TcpLayer, pcpp::SSLApplicationDataLayer, pcpp::HttpResponseLayer, pcpp::SipResponseLayer, pcpp::GtpV1Layer, pcpp::SSLAlertLayer, pcpp::SSHEncryptedMessage, pcpp::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::SSLChangeCipherSpecLayer, pcpp::PPPoEDiscoveryLayer, pcpp::GREv1Layer, pcpp::SSLHandshakeLayer, pcpp::RadiusLayer, pcpp::GREv0Layer, pcpp::SSHHandshakeMessage, pcpp::IgmpLayer, pcpp::SipRequestLayer, pcpp::IPv6Layer, pcpp::HttpRequestLayer, pcpp::ESPLayer, pcpp::PPPoESessionLayer, pcpp::SdpLayer, pcpp::SSHIdentificationMessage, pcpp::EthLayer, pcpp::VxlanLayer, pcpp::ArpLayer, pcpp::VlanLayer, pcpp::AuthenticationHeaderLayer, pcpp::MplsLayer, pcpp::EthDot3Layer, pcpp::BgpLayer, pcpp::SllLayer, pcpp::UdpLayer, pcpp::PayloadLayer, pcpp::NullLoopbackLayer, and pcpp::PacketTrailerLayer.