#[cfg(test)]
mod proto_test;
pub mod addr;
pub mod chandata;
pub mod channum;
pub mod data;
pub mod dontfrag;
pub mod evenport;
pub mod lifetime;
pub mod peeraddr;
pub mod relayaddr;
pub mod reqfamily;
pub mod reqtrans;
pub mod rsrvtoken;
use std::fmt;
use stun::message::*;
#[derive(PartialEq, Eq, Default, Debug, Clone, Copy, Hash)]
pub struct Protocol(pub u8);
pub const PROTO_TCP: Protocol = Protocol(6);
pub const PROTO_UDP: Protocol = Protocol(17);
impl fmt::Display for Protocol {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let others = format!("{}", self.0);
let s = match *self {
PROTO_UDP => "UDP",
PROTO_TCP => "TCP",
_ => others.as_str(),
};
write!(f, "{s}")
}
}
pub const DEFAULT_PORT: u16 = stun::DEFAULT_PORT;
pub const DEFAULT_TLS_PORT: u16 = stun::DEFAULT_TLS_PORT;
pub fn create_permission_request() -> MessageType {
MessageType::new(METHOD_CREATE_PERMISSION, CLASS_REQUEST)
}
pub fn allocate_request() -> MessageType {
MessageType::new(METHOD_ALLOCATE, CLASS_REQUEST)
}
pub fn send_indication() -> MessageType {
MessageType::new(METHOD_SEND, CLASS_INDICATION)
}
pub fn refresh_request() -> MessageType {
MessageType::new(METHOD_REFRESH, CLASS_REQUEST)
}