Skip to main content

turn_types/
message.rs

1// Copyright (C) 2025 Matthew Waters <matthew@centricular.com>
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8//
9// SPDX-License-Identifier: MIT OR Apache-2.0
10
11//! Module for TURN message types in addition to those specified by STUN.
12
13use stun_types::message::Method;
14
15/// The value of the Allocate message type.  Can only be used in a request message.
16pub const ALLOCATE: Method = Method::new(0x0003);
17
18/// The value of the Refresh message type.  Can only be used in a request message.
19pub const REFRESH: Method = Method::new(0x0004);
20
21/// The value of the Send message type.  Can only be used in an indication message.
22pub const SEND: Method = Method::new(0x0006);
23
24/// The value of the Data message type.  Can only be used in an indication message.
25pub const DATA: Method = Method::new(0x0007);
26
27/// The value of the CreatePermission message type.  Can only be used in request message.
28pub const CREATE_PERMISSION: Method = Method::new(0x0008);
29
30/// The value of the ChannelBind message type.  Can only be used in a request message.
31pub const CHANNEL_BIND: Method = Method::new(0x0009);
32
33/// The value of the Connect message type.  Can only be used in a request message.
34pub const CONNECT: Method = Method::new(0x000a);
35
36/// The value of the ConnectionBind message type.  Can only be used in a request message.
37pub const CONNECTION_BIND: Method = Method::new(0x000b);
38
39/// The value of the ConnectionAttempt message type.  Can only be used in a request message.
40pub const CONNECTION_ATTEMPT: Method = Method::new(0x000c);
41
42pub(crate) fn debug_init() {
43    #[cfg(feature = "std")]
44    {
45        ALLOCATE.add_name("ALLOCATE");
46        REFRESH.add_name("REFRESH");
47        SEND.add_name("SEND");
48        DATA.add_name("DATA");
49        CREATE_PERMISSION.add_name("CREATE_PERMISSION");
50        CHANNEL_BIND.add_name("CHANNEL_BIND");
51        CONNECT.add_name("CONNECT");
52        CONNECTION_BIND.add_name("CONNECTION_BIND");
53        CONNECTION_ATTEMPT.add_name("CONNECTION_ATTEMPT");
54    }
55}