33 #include <tins/macros.h> 35 #include <tins/endianness.h> 76 static metadata extract_metadata(
const uint8_t *buffer, uint32_t total_sz);
87 UDP(uint16_t dport = 0, uint16_t sport = 0);
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);
uint16_t checksum() const
Getter for the checksum of the datagram.
Definition: udp.h:130
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
uint16_t sport() const
Getter for the source port.
Definition: udp.h:114
Represents an UDP PDU.
Definition: udp.h:63
The Tins namespace.
Definition: address_range.h:38
UDP * clone() const
Definition: udp.h:182
uint16_t length() const
Getter for the length of the datagram.
Definition: udp.h:122
uint16_t dport() const
Getter for the destination port.
Definition: udp.h:106
Base class for protocol data units.
Definition: pdu.h:107