PcapPlusPlus
pcpp::UdpLayer Class Reference

#include <UdpLayer.h>

Inheritance diagram for pcpp::UdpLayer:
pcpp::Layer

Public Member Functions

 UdpLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 UdpLayer (uint16_t portSrc, uint16_t portDst)
 
udphdrgetUdpHeader ()
 
uint16_t calculateChecksum (bool writeResultToPacket)
 
void parseNextLayer ()
 
size_t getHeaderLen ()
 
void computeCalculateFields ()
 
std::string toString ()
 
OsiModelLayer getOsiModelLayer ()
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer ()
 
LayergetPrevLayer ()
 
ProtocolType getProtocol ()
 
uint8_t * getData ()
 
size_t getDataLen ()
 
uint8_t * getLayerPayload ()
 
size_t getLayerPayloadSize ()
 
bool isAllocatedToPacket ()
 
void copyData (uint8_t *toArr)
 

Detailed Description

Represents an UDP (User Datagram Protocol) protocol layer

Constructor & Destructor Documentation

pcpp::UdpLayer::UdpLayer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 
)
inline

A constructor that creates the layer from an existing packet raw data

Parameters
[in]dataA pointer to the raw data (will be casted to udphdr)
[in]dataLenSize of the data in bytes
[in]prevLayerA pointer to the previous layer
[in]packetA pointer to the Packet instance where layer will be stored in
pcpp::UdpLayer::UdpLayer ( uint16_t  portSrc,
uint16_t  portDst 
)

A constructor that allocates a new UDP header with source and destination ports

Parameters
[in]portSrcSource UDP port address
[in]portDstDestination UDP port

Member Function Documentation

uint16_t pcpp::UdpLayer::calculateChecksum ( bool  writeResultToPacket)

Calculate the checksum from header and data and possibly write the result to udphdr::headerChecksum

Parameters
[in]writeResultToPacketIf set to true then checksum result will be written to udphdr::headerChecksum
Returns
The checksum result
void pcpp::UdpLayer::computeCalculateFields ( )
virtual

Calculate udphdr::headerChecksum field

Implements pcpp::Layer.

size_t pcpp::UdpLayer::getHeaderLen ( )
inlinevirtual
Returns
Size of udphdr

Implements pcpp::Layer.

OsiModelLayer pcpp::UdpLayer::getOsiModelLayer ( )
inlinevirtual
Returns
The OSI Model layer this protocol belongs to

Implements pcpp::Layer.

udphdr* pcpp::UdpLayer::getUdpHeader ( )
inline

Get a pointer to the UDP header. Notice this points directly to the data, so every change will change the actual packet data

Returns
A pointer to the udphdr
void pcpp::UdpLayer::parseNextLayer ( )
virtual

Currently identifies the following next layers: DnsLayer. Otherwise sets PayloadLayer

Implements pcpp::Layer.

std::string pcpp::UdpLayer::toString ( )
virtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.