1use std::io;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
6pub enum McrxError {
7 #[error("MCRX: invalid destination port")]
9 InvalidDestinationPort,
10
11 #[error("MCRX: group must be a multicast IP address")]
13 InvalidMulticastGroup,
14
15 #[error("MCRX: SSM-range multicast groups require a source address")]
17 SsmGroupRequiresSource,
18
19 #[error("MCRX: invalid source address")]
21 InvalidSourceAddress,
22
23 #[error("MCRX: IPv6 SSM groups must use the ff3x:: prefix")]
25 InvalidIpv6SsmGroup,
26
27 #[error("MCRX: IPv4 SSM groups must use the 232.0.0.0/8 range")]
29 InvalidIpv4SsmGroup,
30
31 #[error("MCRX: source address family must match group address family")]
33 SourceAddressFamilyMismatch,
34
35 #[error("MCRX: interface address family must match group address family")]
37 InterfaceAddressFamilyMismatch,
38
39 #[error("MCRX: interface index must be greater than 0")]
41 InvalidInterfaceIndex,
42
43 #[error("MCRX: interface index is only supported for IPv6 subscriptions")]
45 InterfaceIndexRequiresIpv6,
46
47 #[error("MCRX: subscription already exists")]
52 DuplicateSubscription,
53
54 #[error("MCRX: subscription not found")]
56 SubscriptionNotFound,
57
58 #[error("MCRX: subscription not joined")]
60 SubscriptionNotJoined,
61
62 #[error("MCRX: subscription already joined")]
64 SubscriptionAlreadyJoined,
65
66 #[error("MCRX: failed to create UDP socket: {0}")]
68 SocketCreateFailed(io::Error),
69
70 #[error("MCRX: failed to set socket option: {0}")]
72 SocketOptionFailed(io::Error),
73
74 #[error("MCRX: failed to bind UDP socket: {0}")]
76 SocketBindFailed(io::Error),
77
78 #[error("MCRX: failed to create raw receive socket: {0}")]
80 RawSocketCreateFailed(io::Error),
81
82 #[error("MCRX: failed to bind raw receive socket: {0}")]
84 RawSocketBindFailed(io::Error),
85
86 #[error("MCRX: raw multicast receive is not supported on this platform: {0}")]
88 RawPacketReceiveUnsupported(String),
89
90 #[cfg(feature = "raw-shared-capture")]
92 #[error("MCRX: shared raw capture limits must be greater than zero")]
93 InvalidSharedRawCaptureLimits,
94
95 #[cfg(feature = "raw-shared-capture")]
97 #[error("MCRX: shared raw capture subscription limit of {limit} reached")]
98 SharedRawCaptureSubscriptionLimitExceeded { limit: usize },
99
100 #[deprecated(note = "IPv6 receive is implemented; this variant is never returned")]
104 #[error("MCRX: requested IPv6 functionality is not implemented yet")]
105 Ipv6NotYetImplemented,
106
107 #[error("MCRX: invalid subscription address-family combination")]
109 InvalidSubscriptionAddressFamily,
110
111 #[error("MCRX: receive socket setup failed: {0}")]
113 ReceiveSocketSetupFailed(String),
114
115 #[error("MCRX: receive packet did not include destination address metadata")]
118 ReceiveMetadataUnavailable,
119
120 #[error("MCRX: failed to read local address from existing socket: {0}")]
122 SocketLocalAddrFailed(io::Error),
123
124 #[error("MCRX: failed to look up socket extension function: {0}")]
126 SocketIoctlFailed(io::Error),
127
128 #[error("MCRX: existing socket address family does not match the subscription configuration")]
130 ExistingSocketAddressFamilyMismatch,
131
132 #[error("MCRX: existing socket is bound to UDP port {actual}, expected {expected}")]
134 ExistingSocketPortMismatch { expected: u16, actual: u16 },
135
136 #[error("MCRX: failed to join multicast group: {0}")]
138 MulticastJoinFailed(io::Error),
139
140 #[error("MCRX: failed to leave multicast group: {0}")]
142 MulticastLeaveFailed(io::Error),
143
144 #[error("MCRX: source-specific multicast is not supported on this platform")]
146 SourceSpecificMulticastUnsupported,
147
148 #[error(
150 "MCRX: IPv6 source-specific multicast requires an explicit interface address or interface index"
151 )]
152 Ipv6SourceSpecificMulticastRequiresInterface,
153
154 #[deprecated(note = "IPv6 SSM receive is implemented; this variant is never returned")]
158 #[error("MCRX: IPv6 source-specific multicast is not implemented yet")]
159 Ipv6SourceSpecificMulticastNotYetImplemented,
160
161 #[error("MCRX: failed to bind interface probe socket: {0}")]
163 InterfaceProbeBindFailed(io::Error),
164
165 #[error("MCRX: failed to connect interface probe socket: {0}")]
167 InterfaceProbeConnectFailed(io::Error),
168
169 #[error("MCRX: failed to read local address from interface probe socket: {0}")]
171 InterfaceProbeLocalAddrFailed(io::Error),
172
173 #[error("MCRX: failed to discover local interface: {0}")]
175 InterfaceDiscoveryFailed(String),
176
177 #[error("MCRX: received packet from non-IP socket address")]
179 NonIpSocketAddress,
180
181 #[error("MCRX: receive failed: {0}")]
183 ReceiveFailed(io::Error),
184}