26 static_assert(
sizeof(
udphdr) == 8,
"udphdr size is not 8 bytes");
39 :
Layer(data, dataLen, prevLayer, packet,
UDP)
52 return reinterpret_cast<udphdr*
>(m_Data);
71 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen);
98 return data && dataLen >=
sizeof(
udphdr);
Definition: UdpLayer.h:31
udphdr * getUdpHeader() const
Definition: UdpLayer.h:50
OsiModelLayer getOsiModelLayer() const override
Definition: UdpLayer.h:90
uint16_t getDstPort() const
void computeCalculateFields() override
Calculate udphdr::headerChecksum field.
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: UdpLayer.h:96
uint16_t getSrcPort() const
size_t getHeaderLen() const override
Definition: UdpLayer.h:80
void parseNextLayer() override
uint16_t calculateChecksum(bool writeResultToPacket)
UdpLayer(uint16_t portSrc, uint16_t portDst)
UdpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: UdpLayer.h:38
std::string toString() const override
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:225
@ OsiModelTransportLayer
Transport layer (layer 4)
Definition: ProtocolType.h:233
const ProtocolType UDP
UDP protocol.
Definition: ProtocolType.h:38
Definition: UdpLayer.h:15
uint16_t length
Length of header and payload in bytes.
Definition: UdpLayer.h:21
uint16_t portSrc
Source port.
Definition: UdpLayer.h:17
uint16_t portDst
Destination port.
Definition: UdpLayer.h:19
uint16_t headerChecksum
Error-checking of the header and data.
Definition: UdpLayer.h:23