PcapPlusPlus
23.09
|
#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 properties 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::SomeIpSdLayer, pcpp::IcmpLayer, pcpp::NtpLayer, pcpp::IPv4Layer, pcpp::DnsOverTcpLayer, pcpp::IgmpV3ReportLayer, pcpp::SSLApplicationDataLayer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::SomeIpTpLayer, pcpp::SSLAlertLayer, pcpp::DnsLayer, pcpp::DhcpV6Layer, pcpp::PPP_PPTPLayer, pcpp::IgmpV3QueryLayer, pcpp::SSLChangeCipherSpecLayer, pcpp::GREv1Layer, pcpp::SSLHandshakeLayer, pcpp::TelnetLayer, pcpp::RadiusLayer, pcpp::SomeIpLayer, pcpp::IgmpV2Layer, pcpp::VrrpLayer, pcpp::GREv0Layer, pcpp::IgmpV1Layer, pcpp::TextBasedProtocolMessage, pcpp::IPv6Layer, pcpp::NflogLayer, pcpp::StpLayer, pcpp::IcmpV6Layer, pcpp::ESPLayer, pcpp::Sll2Layer, pcpp::WakeOnLanLayer, 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::TpktLayer, pcpp::UdpLayer, pcpp::CotpLayer, pcpp::NullLoopbackLayer, pcpp::PayloadLayer, pcpp::PacketTrailerLayer, pcpp::LLCLayer, and pcpp::FtpLayer.
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::NtpLayer, pcpp::IPv4Layer, pcpp::RapidStpLayer, pcpp::IgmpV3ReportLayer, pcpp::StpConfigurationBPDULayer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::SSHEncryptedMessage, pcpp::DnsLayer, pcpp::DhcpV6Layer, pcpp::PPP_PPTPLayer, pcpp::PPPoEDiscoveryLayer, pcpp::IgmpV3QueryLayer, pcpp::TelnetLayer, pcpp::SomeIpLayer, pcpp::RadiusLayer, pcpp::VrrpLayer, pcpp::StpTopologyChangeBPDULayer, pcpp::SSHHandshakeMessage, pcpp::SSLLayer, pcpp::TextBasedProtocolMessage, pcpp::IgmpLayer, pcpp::NflogLayer, pcpp::IPv6Layer, pcpp::StpLayer, pcpp::IcmpV6Layer, pcpp::Sll2Layer, pcpp::PPPoESessionLayer, pcpp::ESPLayer, pcpp::GreLayer, pcpp::WakeOnLanLayer, pcpp::SSHIdentificationMessage, pcpp::EthLayer, pcpp::VxlanLayer, pcpp::VlanLayer, pcpp::ArpLayer, pcpp::MplsLayer, pcpp::EthDot3Layer, pcpp::AuthenticationHeaderLayer, pcpp::BgpLayer, pcpp::SllLayer, pcpp::TpktLayer, pcpp::UdpLayer, pcpp::NullLoopbackLayer, pcpp::CotpLayer, pcpp::LLCLayer, pcpp::PayloadLayer, pcpp::PacketTrailerLayer, and pcpp::FtpLayer.
|
inline |
|
inline |
|
inline |
|
pure virtual |
Implemented in pcpp::DhcpLayer, pcpp::IcmpLayer, pcpp::NtpLayer, pcpp::IPv4Layer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::DnsLayer, pcpp::DhcpV6Layer, pcpp::PPP_PPTPLayer, pcpp::SomeIpLayer, pcpp::TelnetLayer, pcpp::RadiusLayer, pcpp::VrrpLayer, pcpp::SSLLayer, pcpp::IgmpLayer, pcpp::IPv6Layer, pcpp::NflogLayer, pcpp::StpLayer, pcpp::IcmpV6Layer, pcpp::Sll2Layer, pcpp::ESPLayer, pcpp::WakeOnLanLayer, pcpp::GreLayer, pcpp::SdpLayer, pcpp::EthLayer, pcpp::ArpLayer, pcpp::VxlanLayer, pcpp::VlanLayer, pcpp::AuthenticationHeaderLayer, pcpp::MplsLayer, pcpp::TpktLayer, pcpp::EthDot3Layer, pcpp::CotpLayer, pcpp::BgpLayer, pcpp::SSHLayer, pcpp::HttpMessage, pcpp::SllLayer, pcpp::SipLayer, pcpp::PPPoELayer, pcpp::UdpLayer, pcpp::PayloadLayer, pcpp::NullLoopbackLayer, pcpp::LLCLayer, pcpp::PacketTrailerLayer, and pcpp::FtpLayer.
|
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::MultipleStpLayer, pcpp::DhcpLayer, pcpp::IcmpLayer, pcpp::NtpLayer, pcpp::IPv4Layer, pcpp::RapidStpLayer, pcpp::StpConfigurationBPDULayer, pcpp::TcpLayer, pcpp::GtpV1Layer, pcpp::DhcpV6Layer, pcpp::DnsLayer, pcpp::PPP_PPTPLayer, pcpp::PPPoEDiscoveryLayer, pcpp::SomeIpLayer, pcpp::TelnetLayer, pcpp::RadiusLayer, pcpp::VrrpLayer, pcpp::StpTopologyChangeBPDULayer, pcpp::SSLLayer, pcpp::TextBasedProtocolMessage, pcpp::IgmpLayer, pcpp::NflogLayer, pcpp::IPv6Layer, pcpp::IcmpV6Layer, pcpp::ESPLayer, pcpp::Sll2Layer, pcpp::PPPoESessionLayer, pcpp::GreLayer, pcpp::WakeOnLanLayer, pcpp::EthLayer, pcpp::VxlanLayer, pcpp::VlanLayer, pcpp::ArpLayer, pcpp::AuthenticationHeaderLayer, pcpp::SipLayer, pcpp::BgpLayer, pcpp::MplsLayer, pcpp::SSHLayer, pcpp::EthDot3Layer, pcpp::TpktLayer, pcpp::CotpLayer, pcpp::SllLayer, pcpp::UdpLayer, pcpp::NullLoopbackLayer, pcpp::PayloadLayer, pcpp::PacketTrailerLayer, pcpp::LLCLayer, and pcpp::FtpLayer.
|
pure virtual |
Implemented in pcpp::DhcpLayer, pcpp::MultipleStpLayer, pcpp::SomeIpSdLayer, pcpp::IcmpLayer, pcpp::NtpLayer, pcpp::IPv4Layer, pcpp::RapidStpLayer, pcpp::HttpResponseLayer, pcpp::StpConfigurationBPDULayer, pcpp::FtpDataLayer, pcpp::TcpLayer, pcpp::SSLApplicationDataLayer, pcpp::FtpResponseLayer, pcpp::SipResponseLayer, pcpp::GtpV1Layer, pcpp::SomeIpTpLayer, pcpp::SSLAlertLayer, pcpp::DnsLayer, pcpp::DhcpV6Layer, pcpp::SSHEncryptedMessage, pcpp::PPP_PPTPLayer, pcpp::PPPoEDiscoveryLayer, pcpp::SSLChangeCipherSpecLayer, pcpp::GREv1Layer, pcpp::NDPNeighborAdvertisementLayer, pcpp::SSLHandshakeLayer, pcpp::TelnetLayer, pcpp::SomeIpLayer, pcpp::RadiusLayer, pcpp::VrrpLayer, pcpp::GREv0Layer, pcpp::FtpRequestLayer, pcpp::StpTopologyChangeBPDULayer, pcpp::ICMPv6EchoLayer, pcpp::SSHHandshakeMessage, pcpp::NDPNeighborSolicitationLayer, pcpp::IgmpLayer, pcpp::SipRequestLayer, pcpp::HttpRequestLayer, pcpp::IPv6Layer, pcpp::NflogLayer, pcpp::IcmpV6Layer, pcpp::Sll2Layer, pcpp::ESPLayer, pcpp::PPPoESessionLayer, pcpp::WakeOnLanLayer, pcpp::SdpLayer, pcpp::SSHIdentificationMessage, pcpp::EthLayer, pcpp::ArpLayer, pcpp::VxlanLayer, pcpp::VlanLayer, pcpp::AuthenticationHeaderLayer, pcpp::MplsLayer, pcpp::TpktLayer, pcpp::EthDot3Layer, pcpp::CotpLayer, pcpp::BgpLayer, pcpp::SllLayer, pcpp::UdpLayer, pcpp::PayloadLayer, pcpp::NullLoopbackLayer, pcpp::LLCLayer, and pcpp::PacketTrailerLayer.