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: invalid source address")]
17 InvalidSourceAddress,
18
19 #[error("MCRX: IPv6 SSM groups must use the ff3x:: prefix")]
21 InvalidIpv6SsmGroup,
22
23 #[error("MCRX: source address family must match group address family")]
25 SourceAddressFamilyMismatch,
26
27 #[error("MCRX: interface address family must match group address family")]
29 InterfaceAddressFamilyMismatch,
30
31 #[error("MCRX: interface index must be greater than 0")]
33 InvalidInterfaceIndex,
34
35 #[error("MCRX: interface index is only supported for IPv6 subscriptions")]
37 InterfaceIndexRequiresIpv6,
38
39 #[error("MCRX: subscription already exists")]
41 DuplicateSubscription,
42
43 #[error("MCRX: subscription not found")]
45 SubscriptionNotFound,
46
47 #[error("MCRX: subscription not joined")]
49 SubscriptionNotJoined,
50
51 #[error("MCRX: subscription already joined")]
53 SubscriptionAlreadyJoined,
54
55 #[error("MCRX: failed to create UDP socket: {0}")]
57 SocketCreateFailed(io::Error),
58
59 #[error("MCRX: failed to set socket option: {0}")]
61 SocketOptionFailed(io::Error),
62
63 #[error("MCRX: failed to bind UDP socket: {0}")]
65 SocketBindFailed(io::Error),
66
67 #[error("MCRX: failed to create raw receive socket: {0}")]
69 RawSocketCreateFailed(io::Error),
70
71 #[error("MCRX: failed to bind raw receive socket: {0}")]
73 RawSocketBindFailed(io::Error),
74
75 #[error("MCRX: raw multicast receive is not supported on this platform: {0}")]
77 RawPacketReceiveUnsupported(String),
78
79 #[error("MCRX: requested IPv6 functionality is not implemented yet")]
81 Ipv6NotYetImplemented,
82
83 #[error("MCRX: failed to read local address from existing socket: {0}")]
85 SocketLocalAddrFailed(io::Error),
86
87 #[error("MCRX: failed to look up socket extension function: {0}")]
89 SocketIoctlFailed(io::Error),
90
91 #[error("MCRX: existing socket address family does not match the subscription configuration")]
93 ExistingSocketAddressFamilyMismatch,
94
95 #[error("MCRX: existing socket is bound to UDP port {actual}, expected {expected}")]
97 ExistingSocketPortMismatch { expected: u16, actual: u16 },
98
99 #[error("MCRX: failed to join multicast group: {0}")]
101 MulticastJoinFailed(io::Error),
102
103 #[error("MCRX: failed to leave multicast group: {0}")]
105 MulticastLeaveFailed(io::Error),
106
107 #[error("MCRX: source-specific multicast is not supported on this platform")]
109 SourceSpecificMulticastUnsupported,
110
111 #[error(
113 "MCRX: IPv6 source-specific multicast requires an explicit interface address or interface index"
114 )]
115 Ipv6SourceSpecificMulticastRequiresInterface,
116
117 #[error("MCRX: IPv6 source-specific multicast is not implemented yet")]
119 Ipv6SourceSpecificMulticastNotYetImplemented,
120
121 #[error("MCRX: failed to bind interface probe socket: {0}")]
123 InterfaceProbeBindFailed(io::Error),
124
125 #[error("MCRX: failed to connect interface probe socket: {0}")]
127 InterfaceProbeConnectFailed(io::Error),
128
129 #[error("MCRX: failed to read local address from interface probe socket: {0}")]
131 InterfaceProbeLocalAddrFailed(io::Error),
132
133 #[error("MCRX: failed to discover local interface: {0}")]
135 InterfaceDiscoveryFailed(String),
136
137 #[error("MCRX: received packet from non-IP socket address")]
139 NonIpSocketAddress,
140
141 #[error("MCRX: receive failed: {0}")]
143 ReceiveFailed(io::Error),
144}