PcapPlusPlus
19.12
|
#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::IgmpV3ReportLayer, pcpp::SSLApplicationDataLayer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::SSLAlertLayer, pcpp::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::IgmpV3QueryLayer, pcpp::SSLChangeCipherSpecLayer, pcpp::GREv1Layer, pcpp::SSLHandshakeLayer, pcpp::IgmpV2Layer, pcpp::RadiusLayer, 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 | ) | 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::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::IgmpV3QueryLayer, pcpp::PPPoEDiscoveryLayer, pcpp::RadiusLayer, 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::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::RadiusLayer, 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::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::PPPoEDiscoveryLayer, pcpp::RadiusLayer, 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::DhcpLayer, pcpp::IcmpLayer, pcpp::IPv4Layer, pcpp::SSLApplicationDataLayer, pcpp::HttpResponseLayer, pcpp::TcpLayer, pcpp::SipResponseLayer, pcpp::GtpV1Layer, pcpp::SSLAlertLayer, pcpp::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::SSLChangeCipherSpecLayer, pcpp::PPPoEDiscoveryLayer, pcpp::GREv1Layer, pcpp::SSLHandshakeLayer, pcpp::RadiusLayer, 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.