Skip to main content

Module util

Module util 

Source
Expand description

Small shared helpers: packet demultiplexing predicates and random-string generation. Shared helpers: packet demultiplexing and random strings.

WebRTC multiplexes STUN, DTLS and SRTP onto one port, so the first byte of a datagram decides which layer receives it (RFC 7983). The match_* predicates implement those ranges, and is_rtcp separates RTCP from RTP once a packet is known to be one of the two.

Functions§

generate_crypto_random_string
Generates a random n-character string drawn from runes.
is_rtcp
Returns true if buf is RTCP rather than RTP.
lookup_host
lookup host to SocketAddr
match_dtls
MatchFuncs as described in RFC7983 https://tools.ietf.org/html/rfc7983 +––––––––+ | [0..3] -+–> forward to STUN | | | [16..19] -+–> forward to ZRTP | | packet –> | [20..63] -+–> forward to DTLS | | | [64..79] -+–> forward to TURN Channel | | | [128..191] -+–> forward to RTP/RTCP +––––––––+ match_dtls is a MatchFunc that accepts packets with the first byte in [20..63] as defied in RFC7983
match_srtcp
match_srtcp is a MatchFunc that only matches SRTCP and not SRTP
match_srtp
match_srtp is a MatchFunc that only matches SRTP and not SRTCP
match_srtp_or_srtcp
Returns true if b looks like SRTP or SRTCP: its first byte is in [128, 191].
math_rand_alpha
math_rand_alpha generates a mathematical random alphabet sequence of the requested length.
math_rand_alpha_number
math_rand_alpha generates a mathematical random alphabet and number sequence of the requested length.