pub struct Repr {
pub src_port: u16,
pub dst_port: u16,
pub length: u16,
}Expand description
A high-level representation of an User Datagram Protocol packet.
Fields§
§src_port: u16§dst_port: u16§length: u16Implementations§
Source§impl Repr
impl Repr
Sourcepub fn parse(packet: &udp, checksum: Checksum) -> Result<Repr>
pub fn parse(packet: &udp, checksum: Checksum) -> Result<Repr>
Parse an User Datagram Protocol packet and return a high-level representation.
Sourcepub fn buffer_len(&self) -> usize
pub fn buffer_len(&self) -> usize
Return the length of a packet that will be emitted from this high-level representation.
Sourcepub fn emit(&self, packet: &mut udp, checksum: Checksum)
pub fn emit(&self, packet: &mut udp, checksum: Checksum)
Emit a high-level representation into an User Datagram Protocol packet.
Note: In most cases you will want to use Checksum::Ignored. Calculating requires the
correct packet data to already be present. However, the payload slice returned from the
packet will only be valid after the length is correctly filled in.
However, Checksum::Manual is still useful if the payload was mutated with external means.
It could also be possible to update the checksum incrementally if only few bytes are
required to have concrete values, however no means are provided in thie library and you’d
have to implement such schemes yourself.