Skip to main content

mcrx_core/
error.rs

1use std::io;
2use thiserror::Error;
3
4/// Errors returned by the multicast receiver core.
5#[derive(Debug, Error)]
6pub enum McrxError {
7    /// The configured destination port is invalid.
8    #[error("MCRX: invalid destination port")]
9    InvalidDestinationPort,
10
11    /// The configured group address is not a valid multicast IP address.
12    #[error("MCRX: group must be a multicast IP address")]
13    InvalidMulticastGroup,
14
15    /// The configured SSM source address is invalid.
16    #[error("MCRX: invalid source address")]
17    InvalidSourceAddress,
18
19    /// The configured IPv6 SSM group is not in the IPv6 SSM range.
20    #[error("MCRX: IPv6 SSM groups must use the ff3x:: prefix")]
21    InvalidIpv6SsmGroup,
22
23    /// The configured SSM source address family does not match the group family.
24    #[error("MCRX: source address family must match group address family")]
25    SourceAddressFamilyMismatch,
26
27    /// The configured interface address family does not match the group family.
28    #[error("MCRX: interface address family must match group address family")]
29    InterfaceAddressFamilyMismatch,
30
31    /// The configured interface index is invalid.
32    #[error("MCRX: interface index must be greater than 0")]
33    InvalidInterfaceIndex,
34
35    /// The configured interface index is only valid for IPv6 subscriptions.
36    #[error("MCRX: interface index is only supported for IPv6 subscriptions")]
37    InterfaceIndexRequiresIpv6,
38
39    /// A subscription with the same configuration already exists.
40    #[error("MCRX: subscription already exists")]
41    DuplicateSubscription,
42
43    /// No subscription with the requested ID exists.
44    #[error("MCRX: subscription not found")]
45    SubscriptionNotFound,
46
47    /// The subscription is not currently joined to its multicast group.
48    #[error("MCRX: subscription not joined")]
49    SubscriptionNotJoined,
50
51    /// The subscription is already joined to its multicast group.
52    #[error("MCRX: subscription already joined")]
53    SubscriptionAlreadyJoined,
54
55    /// Creating the UDP socket failed.
56    #[error("MCRX: failed to create UDP socket: {0}")]
57    SocketCreateFailed(io::Error),
58
59    /// Setting a socket option failed.
60    #[error("MCRX: failed to set socket option: {0}")]
61    SocketOptionFailed(io::Error),
62
63    /// Binding the UDP socket failed.
64    #[error("MCRX: failed to bind UDP socket: {0}")]
65    SocketBindFailed(io::Error),
66
67    /// Creating the raw receive socket failed.
68    #[error("MCRX: failed to create raw receive socket: {0}")]
69    RawSocketCreateFailed(io::Error),
70
71    /// Binding the raw receive socket failed.
72    #[error("MCRX: failed to bind raw receive socket: {0}")]
73    RawSocketBindFailed(io::Error),
74
75    /// Raw multicast receive is not supported on this platform in this build.
76    #[error("MCRX: raw multicast receive is not supported on this platform: {0}")]
77    RawPacketReceiveUnsupported(String),
78
79    /// The requested IPv6 functionality is not implemented yet.
80    #[error("MCRX: requested IPv6 functionality is not implemented yet")]
81    Ipv6NotYetImplemented,
82
83    /// Reading the local address of an existing socket failed.
84    #[error("MCRX: failed to read local address from existing socket: {0}")]
85    SocketLocalAddrFailed(io::Error),
86
87    /// Looking up a socket extension function failed.
88    #[error("MCRX: failed to look up socket extension function: {0}")]
89    SocketIoctlFailed(io::Error),
90
91    /// The provided existing socket family does not match the subscription configuration.
92    #[error("MCRX: existing socket address family does not match the subscription configuration")]
93    ExistingSocketAddressFamilyMismatch,
94
95    /// The provided existing socket is bound to a different UDP port than the subscription.
96    #[error("MCRX: existing socket is bound to UDP port {actual}, expected {expected}")]
97    ExistingSocketPortMismatch { expected: u16, actual: u16 },
98
99    /// Joining a multicast group failed.
100    #[error("MCRX: failed to join multicast group: {0}")]
101    MulticastJoinFailed(io::Error),
102
103    /// Leaving a multicast group failed.
104    #[error("MCRX: failed to leave multicast group: {0}")]
105    MulticastLeaveFailed(io::Error),
106
107    /// Source-specific multicast is not supported on this platform.
108    #[error("MCRX: source-specific multicast is not supported on this platform")]
109    SourceSpecificMulticastUnsupported,
110
111    /// IPv6 source-specific multicast requires explicit interface selection.
112    #[error(
113        "MCRX: IPv6 source-specific multicast requires an explicit interface address or interface index"
114    )]
115    Ipv6SourceSpecificMulticastRequiresInterface,
116
117    /// IPv6 source-specific multicast has not been wired into the receiver yet.
118    #[error("MCRX: IPv6 source-specific multicast is not implemented yet")]
119    Ipv6SourceSpecificMulticastNotYetImplemented,
120
121    /// Binding the interface probe socket failed.
122    #[error("MCRX: failed to bind interface probe socket: {0}")]
123    InterfaceProbeBindFailed(io::Error),
124
125    /// Connecting the interface probe socket failed.
126    #[error("MCRX: failed to connect interface probe socket: {0}")]
127    InterfaceProbeConnectFailed(io::Error),
128
129    /// Reading the local address from the interface probe socket failed.
130    #[error("MCRX: failed to read local address from interface probe socket: {0}")]
131    InterfaceProbeLocalAddrFailed(io::Error),
132
133    /// Discovering the local network interface failed.
134    #[error("MCRX: failed to discover local interface: {0}")]
135    InterfaceDiscoveryFailed(String),
136
137    /// The received packet came from a non-IP socket address.
138    #[error("MCRX: received packet from non-IP socket address")]
139    NonIpSocketAddress,
140
141    /// Receiving a packet failed.
142    #[error("MCRX: receive failed: {0}")]
143    ReceiveFailed(io::Error),
144}