Skip to main content

classify_datagram

Function classify_datagram 

Source
pub fn classify_datagram(packet: &[u8]) -> Option<DatagramKind>
Expand description

Classifies STUN, DTLS 1.0/1.2, RTP/SRTP or RTCP/SRTCP by header shape.

Returns None for unsupported multiplexed protocols or truncated framing. STUN requires the RFC 8489 cookie and exact aligned message length. DTLS requires one complete initial record. RTP requires its fixed header, CSRC list and declared extension block. RTCP requires an initial packet header, sender SSRC and declared initial packet length, allowing compound packets and SRTCP trailers.

These shallow checks do not validate STUN attributes, subsequent DTLS/RTCP records, RTP payloads or padding. They do not authenticate or decrypt data and cannot distinguish protected packets from plaintext packets.

References: