1#[cfg(test)]
2mod proto_test;
3
4pub mod addr;
5pub mod chandata;
6pub mod channum;
7pub mod data;
8pub mod dontfrag;
9pub mod evenport;
10pub mod lifetime;
11pub mod peeraddr;
12pub mod relayaddr;
13pub mod reqfamily;
14pub mod reqtrans;
15pub mod rsrvtoken;
16
17use std::fmt;
18
19use stun::message::*;
20
21#[derive(PartialEq, Eq, Default, Debug, Clone, Copy, Hash)]
25pub struct Protocol(pub u8);
26
27pub const PROTO_TCP: Protocol = Protocol(6);
29pub const PROTO_UDP: Protocol = Protocol(17);
31
32impl fmt::Display for Protocol {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 let others = format!("{}", self.0);
35 let s = match *self {
36 PROTO_UDP => "UDP",
37 PROTO_TCP => "TCP",
38 _ => others.as_str(),
39 };
40
41 write!(f, "{s}")
42 }
43}
44
45pub const DEFAULT_PORT: u16 = stun::DEFAULT_PORT;
49pub const DEFAULT_TLS_PORT: u16 = stun::DEFAULT_TLS_PORT;
51
52pub fn create_permission_request() -> MessageType {
54 MessageType::new(METHOD_CREATE_PERMISSION, CLASS_REQUEST)
55}
56
57pub fn allocate_request() -> MessageType {
59 MessageType::new(METHOD_ALLOCATE, CLASS_REQUEST)
60}
61
62pub fn send_indication() -> MessageType {
64 MessageType::new(METHOD_SEND, CLASS_INDICATION)
65}
66
67pub fn refresh_request() -> MessageType {
69 MessageType::new(METHOD_REFRESH, CLASS_REQUEST)
70}