srt_protocol/options/
error.rs1use std::{io, io::ErrorKind, net::IpAddr, time::Duration};
2
3use thiserror::Error;
4
5use crate::options::*;
6
7#[derive(Error, Clone, Debug, Eq, PartialEq)]
9pub enum OptionsError {
10 #[error("KM Refresh Period ({0}) must be non-zero and greater than 1/2 the KM Pre Announce Period ({1}).")]
11 KeyMaterialRefresh(PacketCount, PacketCount),
12 #[error("Invalid password length: {0}. The password must be minimum 10 and maximum 79 characters long.")]
13 PassphraseLength(usize),
14 #[error("Invalid encryption key size: {0}. Valid sizes are 16, 24, or 32 bytes.")]
15 InvalidKeySize(u16),
16
17 #[error("MMS out of range: {0}. The maximum size of a UDP packet is 1500 bytes.")]
18 MaxSegmentSizeOutOfRange(PacketSize),
19
20 #[error("Receive buffer too small {0}")]
21 ReceiveBufferMin(ByteCount),
22
23 #[error("Receive buffer too big - buffer: {buffer}, max_segment: {max_segment}, flow_control_window: {flow_control_window}")]
24 ReceiveBufferTooLarge {
25 buffer: ByteCount,
26 max_segment: PacketSize,
27 flow_control_window: PacketCount,
28 },
29
30 #[error("UDP Receive buffer larger than flow window, flow window={flow_control_window} mss={max_segment}, receive buffer={udp_buffer}")]
31 UdpReceiveBufferTooLarge {
32 udp_buffer: ByteCount,
33 max_segment: PacketSize,
34 flow_control_window: PacketCount,
35 },
36
37 #[error("UDP Send buffer larger than flow window, flow window={flow_control_window} mss={max_segment}, receive buffer={udp_buffer}")]
38 UdpSenderBufferTooLarge {
39 udp_buffer: ByteCount,
40 max_segment: PacketSize,
41 flow_control_window: PacketCount,
42 },
43
44 #[error("Sender flow_control_window_size {0} is less than the minimum 32 packets")]
45 FlowControlWindowMin(PacketCount),
46
47 #[error("A specific local port is required to listen for incoming callers.")]
48 LocalPortRequiredToListen,
49
50 #[error("Mismatched remote address and local address family. remote: {0} local {1}")]
51 MismatchedAddressFamilies(IpAddr, IpAddr),
52
53 #[error("Invalid remote address")]
54 InvalidRemoteAddress,
55
56 #[error("Invalid local address")]
57 InvalidLocalAddress,
58
59 #[error("Invalid Stream Id {0}")]
60 InvalidStreamId(StreamIdError),
61
62 #[error("IP TTL is invalid, must be > 0")]
63 InvalidIpTtl,
64
65 #[error("Statistics interval is out of range: {0:?}. The minimum interval is 200ms.")]
66 StatisticsIntervalOutOfRange(Duration),
67}
68
69impl From<OptionsError> for io::Error {
70 fn from(error: OptionsError) -> Self {
71 Self::new(ErrorKind::InvalidInput, error)
72 }
73}