52 lines
1.7 KiB
Rust
52 lines
1.7 KiB
Rust
//! Central constants for STUN/TURN implementations (magic cookie, attribute types, methods)
|
|
|
|
pub const MAGIC_COOKIE_U32: u32 = 0x2112A442;
|
|
pub const MAGIC_COOKIE_BYTES: [u8; 4] = MAGIC_COOKIE_U32.to_be_bytes();
|
|
|
|
// STUN Methods/Message Types (only those used in this MVP)
|
|
pub const METHOD_BINDING: u16 = 0x0001;
|
|
pub const METHOD_ALLOCATE: u16 = 0x0003;
|
|
pub const METHOD_CREATE_PERMISSION: u16 = 0x0008;
|
|
pub const METHOD_REFRESH: u16 = 0x0004;
|
|
pub const METHOD_SEND: u16 = 0x0006;
|
|
pub const METHOD_DATA: u16 = 0x0007;
|
|
pub const METHOD_CHANNEL_BIND: u16 = 0x0009;
|
|
|
|
// STUN/TURN class bits per RFC5389/RFC5766
|
|
pub const CLASS_SUCCESS: u16 = 0x0100;
|
|
pub const CLASS_ERROR: u16 = 0x0110;
|
|
pub const CLASS_INDICATION: u16 = 0x0010;
|
|
|
|
// Common attribute types
|
|
pub const ATTR_USERNAME: u16 = 0x0006;
|
|
pub const ATTR_MESSAGE_INTEGRITY: u16 = 0x0008;
|
|
pub const ATTR_ERROR_CODE: u16 = 0x0009;
|
|
pub const ATTR_CHANNEL_NUMBER: u16 = 0x000C;
|
|
pub const ATTR_LIFETIME: u16 = 0x000D;
|
|
pub const ATTR_REALM: u16 = 0x0014;
|
|
pub const ATTR_NONCE: u16 = 0x0015;
|
|
pub const ATTR_XOR_PEER_ADDRESS: u16 = 0x0012;
|
|
pub const ATTR_XOR_MAPPED_ADDRESS: u16 = 0x0020;
|
|
|
|
// RFC5389: FINGERPRINT
|
|
pub const ATTR_FINGERPRINT: u16 = 0x8028;
|
|
|
|
// TURN attrs
|
|
pub const ATTR_XOR_RELAYED_ADDRESS: u16 = 0x0016;
|
|
pub const ATTR_DATA: u16 = 0x0013;
|
|
pub const ATTR_REQUESTED_TRANSPORT: u16 = 0x0019;
|
|
|
|
// IP protocol numbers used by TURN REQUESTED-TRANSPORT
|
|
pub const IPPROTO_UDP: u8 = 17;
|
|
pub const IPPROTO_TCP: u8 = 6;
|
|
|
|
// Some helper values
|
|
pub const FAMILY_IPV4: u8 = 0x01;
|
|
pub const FAMILY_IPV6: u8 = 0x02;
|
|
|
|
// Fingerprint XOR magic (XOR with CRC32 for FINGERPRINT attribute)
|
|
pub const FINGERPRINT_XOR: u32 = 0x5354554e;
|
|
|
|
// Length of HMAC-SHA1 (MESSAGE-INTEGRITY)
|
|
pub const HMAC_SHA1_LEN: usize = 20;
|