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:
- https://www.rfc-editor.org/rfc/rfc7983.html#section-7
- https://www.rfc-editor.org/rfc/rfc8489.html#section-5
- https://www.rfc-editor.org/rfc/rfc4347.html#section-4.1
- https://www.rfc-editor.org/rfc/rfc6347.html#section-4.1
- https://www.rfc-editor.org/rfc/rfc3550.html#section-5.1
- https://www.rfc-editor.org/rfc/rfc3550.html#section-6.4.1
- https://www.rfc-editor.org/rfc/rfc5761.html#section-4
- https://www.rfc-editor.org/rfc/rfc3711.html#section-3.4