pub fn is_stun(datagram: &[u8]) -> boolExpand description
Whether a datagram is STUN rather than SIP (RFC 5389 §7.3).
Two checks, both from §7.3: “the most significant 2 bits of every STUN message MUST be zeroes”,
and the magic cookie. Demultiplexing on the same socket is what §4.4.2’s keep-alive requires —
the ping has to travel over the very flow it is testing — and this is the test the RFC gives
for doing it. A SIP message cannot collide: its first byte is a method letter or S, all of
which have a high bit set within the first two bits’ meaning here (0x53 is 0101…, whose top
two bits are 01), and the cookie makes a collision beyond that vanishingly unlikely.