webrtc_turn/
errors.rs

1use util::Error;
2
3lazy_static! {
4    pub static ref ERR_RELAY_ADDRESS_INVALID: Error = Error::new(
5        "turn: RelayAddress must be valid IP to use RelayAddressGeneratorStatic".to_owned()
6    );
7    pub static ref ERR_NO_AVAILABLE_CONNS: Error = Error::new(
8        "turn: PacketConnConfigs and ConnConfigs are empty, unable to proceed".to_owned()
9    );
10    pub static ref ERR_CONN_UNSET: Error =
11        Error::new("turn: PacketConnConfig must have a non-nil Conn".to_owned());
12    pub static ref ERR_LISTENER_UNSET: Error =
13        Error::new("turn: ListenerConfig must have a non-nil Listener".to_owned());
14    pub static ref ERR_LISTENING_ADDRESS_INVALID: Error =
15        Error::new("turn: RelayAddressGenerator has invalid ListeningAddress".to_owned());
16    pub static ref ERR_RELAY_ADDRESS_GENERATOR_UNSET: Error =
17        Error::new("turn: RelayAddressGenerator in RelayConfig is unset".to_owned());
18    pub static ref ERR_MAX_RETRIES_EXCEEDED: Error =
19        Error::new("turn: max retries exceeded".to_owned());
20    pub static ref ERR_MAX_PORT_NOT_ZERO: Error =
21        Error::new("turn: MaxPort must be not 0".to_owned());
22    pub static ref ERR_MIN_PORT_NOT_ZERO: Error =
23        Error::new("turn: MaxPort must be not 0".to_owned());
24    pub static ref ERR_MAX_PORT_LESS_THAN_MIN_PORT: Error =
25        Error::new("turn: MaxPort less than MinPort".to_owned());
26    pub static ref ERR_NIL_CONN: Error = Error::new("turn: relay_conn cannot not be nil".to_owned());
27    pub static ref ERR_TODO: Error = Error::new("turn: TODO".to_owned());
28    pub static ref ERR_ALREADY_LISTENING: Error = Error::new("turn: already listening".to_owned());
29    pub static ref ERR_FAILED_TO_CLOSE: Error =
30        Error::new("turn: Server failed to close".to_owned());
31    pub static ref ERR_FAILED_TO_RETRANSMIT_TRANSACTION: Error =
32        Error::new("turn: failed to retransmit transaction".to_owned());
33    pub static ref ERR_ALL_RETRANSMISSIONS_FAILED: Error =
34        Error::new("all retransmissions failed for".to_owned());
35    pub static ref ERR_CHANNEL_BIND_NOT_FOUND: Error =
36        Error::new("no binding found for channel".to_owned());
37    pub static ref ERR_STUNSERVER_ADDRESS_NOT_SET: Error =
38        Error::new("STUN server address is not set for the client".to_owned());
39    pub static ref ERR_ONE_ALLOCATE_ONLY: Error =
40        Error::new("only one Allocate() caller is allowed".to_owned());
41    pub static ref ERR_ALREADY_ALLOCATED: Error = Error::new("already allocated".to_owned());
42    pub static ref ERR_NON_STUNMESSAGE: Error =
43        Error::new("non-STUN message from STUN server".to_owned());
44    pub static ref ERR_FAILED_TO_DECODE_STUN: Error =
45        Error::new("failed to decode STUN message".to_owned());
46    pub static ref ERR_UNEXPECTED_STUNREQUEST_MESSAGE: Error =
47        Error::new("unexpected STUN request message".to_owned());
48
49    // ErrInvalidChannelNumber means that channel number is not valid as by RFC 5766 Section 11.
50    pub static ref ERR_INVALID_CHANNEL_NUMBER: Error =
51        Error::new("channel number not in [0x4000, 0x7FFF]".to_owned());
52    // ErrBadChannelDataLength means that channel data length is not equal
53    // to actual data length.
54    pub static ref ERR_BAD_CHANNEL_DATA_LENGTH: Error =
55        Error::new("channelData length != len(Data)".to_owned());
56    pub static ref ERR_UNEXPECTED_EOF: Error = Error::new("unexpected EOF".to_owned());
57    pub static ref ERR_INVALID_REQUESTED_FAMILY_VALUE: Error = Error::new("invalid value for requested family attribute".to_owned());
58
59    pub static ref ERR_FAKE_ERR: Error = Error::new("fake error".to_owned());
60    pub static ref ERR_TRY_AGAIN: Error = Error::new("try again".to_owned());
61    pub static ref ERR_CLOSED: Error = Error::new("use of closed network connection".to_owned());
62    pub static ref ERR_UDPADDR_CAST: Error = Error::new("addr is not a net.UDPAddr".to_owned());
63    pub static ref ERR_ALREADY_CLOSED: Error = Error::new("already closed".to_owned());
64    pub static ref ERR_DOUBLE_LOCK: Error = Error::new("try-lock is already locked".to_owned());
65    pub static ref ERR_TRANSACTION_CLOSED: Error = Error::new("transaction closed".to_owned());
66    pub static ref ERR_WAIT_FOR_RESULT_ON_NON_RESULT_TRANSACTION: Error = Error::new("wait_for_result called on non-result transaction".to_owned());
67    pub static ref ERR_FAILED_TO_BUILD_REFRESH_REQUEST: Error = Error::new("failed to build refresh request".to_owned());
68    pub static ref ERR_FAILED_TO_REFRESH_ALLOCATION: Error = Error::new("failed to refresh allocation".to_owned());
69    pub static ref ERR_FAILED_TO_GET_LIFETIME: Error = Error::new("failed to get lifetime from refresh response".to_owned());
70    pub static ref ERR_SHORT_BUFFER: Error = Error::new("too short buffer".to_owned());
71    pub static ref ERR_UNEXPECTED_RESPONSE: Error = Error::new("unexpected response type".to_owned());
72
73    pub static ref ERR_ALLOCATE_PACKET_CONN_MUST_BE_SET: Error = Error::new("AllocatePacketConn must be set".to_owned());
74    pub static ref ERR_ALLOCATE_CONN_MUST_BE_SET: Error = Error::new("AllocateConn must be set".to_owned());
75    pub static ref ERR_LEVELED_LOGGER_MUST_BE_SET: Error = Error::new("LeveledLogger must be set".to_owned());
76    pub static ref ERR_SAME_CHANNEL_DIFFERENT_PEER: Error = Error::new("you cannot use the same channel number with different peer".to_owned());
77    pub static ref ERR_NIL_FIVE_TUPLE: Error = Error::new("allocations must not be created with nil FivTuple".to_owned());
78    pub static ref ERR_NIL_FIVE_TUPLE_SRC_ADDR: Error = Error::new("allocations must not be created with nil FiveTuple.src_addr".to_owned());
79    pub static ref ERR_NIL_FIVE_TUPLE_DST_ADDR: Error = Error::new("allocations must not be created with nil FiveTuple.dst_addr".to_owned());
80    pub static ref ERR_NIL_TURN_SOCKET: Error = Error::new("allocations must not be created with nil turnSocket".to_owned());
81    pub static ref ERR_LIFETIME_ZERO: Error = Error::new("allocations must not be created with a lifetime of 0".to_owned());
82    pub static ref ERR_DUPE_FIVE_TUPLE: Error = Error::new("allocation attempt created with duplicate FiveTuple".to_owned());
83    pub static ref ERR_FAILED_TO_CAST_UDPADDR: Error = Error::new("failed to cast net.Addr to *net.UDPAddr".to_owned());
84
85    pub static ref ERR_FAILED_TO_GENERATE_NONCE: Error = Error::new("failed to generate nonce".to_owned());
86    pub static ref ERR_FAILED_TO_SEND_ERROR: Error = Error::new("failed to send error message".to_owned());
87    pub static ref ERR_DUPLICATED_NONCE: Error = Error::new("duplicated Nonce generated, discarding request".to_owned());
88    pub static ref ERR_NO_SUCH_USER: Error = Error::new("no such user exists".to_owned());
89    pub static ref ERR_UNEXPECTED_CLASS: Error = Error::new("unexpected class".to_owned());
90    pub static ref ERR_UNEXPECTED_METHOD: Error = Error::new("unexpected method".to_owned());
91    pub static ref ERR_FAILED_TO_HANDLE: Error = Error::new("failed to handle".to_owned());
92    pub static ref ERR_UNHANDLED_STUNPACKET: Error = Error::new("unhandled STUN packet".to_owned());
93    pub static ref ERR_UNABLE_TO_HANDLE_CHANNEL_DATA: Error = Error::new("unable to handle ChannelData".to_owned());
94    pub static ref ERR_FAILED_TO_CREATE_STUNPACKET: Error = Error::new("failed to create stun message from packet".to_owned());
95    pub static ref ERR_FAILED_TO_CREATE_CHANNEL_DATA: Error = Error::new("failed to create channel data from packet".to_owned());
96    pub static ref ERR_RELAY_ALREADY_ALLOCATED_FOR_FIVE_TUPLE: Error = Error::new("relay already allocated for 5-TUPLE".to_owned());
97    pub static ref ERR_REQUESTED_TRANSPORT_MUST_BE_UDP: Error = Error::new("RequestedTransport must be UDP".to_owned());
98    pub static ref ERR_NO_DONT_FRAGMENT_SUPPORT: Error = Error::new("no support for DONT-FRAGMENT".to_owned());
99    pub static ref ERR_REQUEST_WITH_RESERVATION_TOKEN_AND_EVEN_PORT: Error = Error::new("Request must not contain RESERVATION-TOKEN and EVEN-PORT".to_owned());
100    pub static ref ERR_NO_ALLOCATION_FOUND: Error = Error::new("no allocation found".to_owned());
101    pub static ref ERR_NO_PERMISSION: Error = Error::new("unable to handle send-indication, no permission added".to_owned());
102    pub static ref ERR_SHORT_WRITE: Error = Error::new("packet write smaller than packet".to_owned());
103    pub static ref ERR_NO_SUCH_CHANNEL_BIND: Error = Error::new("no such channel bind".to_owned());
104    pub static ref ERR_FAILED_WRITE_SOCKET: Error = Error::new("failed writing to socket".to_owned());
105
106}