33#include <tins/macros.h>
35#include <tins/endianness.h>
100 UDP(
const uint8_t* buffer, uint32_t total_sz);
107 return Endian::be_to_host(header_.dport);
115 return Endian::be_to_host(header_.sport);
123 return Endian::be_to_host(header_.len);
131 return Endian::be_to_host(header_.check);
138 void dport(uint16_t new_dport);
145 void sport(uint16_t new_sport);
151 void length(uint16_t new_len);
163 bool matches_response(
const uint8_t* ptr, uint32_t total_sz)
const;
171 uint32_t header_size()
const;
183 return new UDP(*
this);
194 void write_serialization(uint8_t* buffer, uint32_t total_sz);
PDU()
Default constructor.
Definition pdu.cpp:50
PDUType
Enum which identifies each type of PDU.
Definition pdu.h:127
PDUType pdu_type() const
Getter for the PDU's type.
Definition udp.h:177
static metadata extract_metadata(const uint8_t *buffer, uint32_t total_sz)
Extracts metadata for this protocol based on the buffer provided.
Definition udp.cpp:45
UDP * clone() const
Definition udp.h:182
static const PDU::PDUType pdu_flag
This PDU's flag.
Definition udp.h:68
uint16_t length() const
Getter for the length of the datagram.
Definition udp.h:122
UDP(uint16_t dport=0, uint16_t sport=0)
UDP constructor.
Definition udp.cpp:52
uint16_t checksum() const
Getter for the checksum of the datagram.
Definition udp.h:130
uint16_t dport() const
Getter for the destination port.
Definition udp.h:106
uint16_t sport() const
Getter for the source port.
Definition udp.h:114
The Tins namespace.
Definition address_range.h:38