sctp_async/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, Error, PartialEq)]
6#[non_exhaustive]
7pub enum Error {
8    #[error("raw is too small for a SCTP chunk")]
9    ErrChunkHeaderTooSmall,
10    #[error("not enough data left in SCTP packet to satisfy requested length")]
11    ErrChunkHeaderNotEnoughSpace,
12    #[error("chunk PADDING is non-zero at offset")]
13    ErrChunkHeaderPaddingNonZero,
14    #[error("chunk has invalid length")]
15    ErrChunkHeaderInvalidLength,
16
17    #[error("ChunkType is not of type ABORT")]
18    ErrChunkTypeNotAbort,
19    #[error("failed build Abort Chunk")]
20    ErrBuildAbortChunkFailed,
21    #[error("ChunkType is not of type COOKIEACK")]
22    ErrChunkTypeNotCookieAck,
23    #[error("ChunkType is not of type COOKIEECHO")]
24    ErrChunkTypeNotCookieEcho,
25    #[error("ChunkType is not of type ctError")]
26    ErrChunkTypeNotCtError,
27    #[error("failed build Error Chunk")]
28    ErrBuildErrorChunkFailed,
29    #[error("failed to marshal stream")]
30    ErrMarshalStreamFailed,
31    #[error("chunk too short")]
32    ErrChunkTooShort,
33    #[error("ChunkType is not of type ForwardTsn")]
34    ErrChunkTypeNotForwardTsn,
35    #[error("ChunkType is not of type HEARTBEAT")]
36    ErrChunkTypeNotHeartbeat,
37    #[error("ChunkType is not of type HEARTBEATACK")]
38    ErrChunkTypeNotHeartbeatAck,
39    #[error("heartbeat is not long enough to contain Heartbeat Info")]
40    ErrHeartbeatNotLongEnoughInfo,
41    #[error("failed to parse param type")]
42    ErrParseParamTypeFailed,
43    #[error("heartbeat should only have HEARTBEAT param")]
44    ErrHeartbeatParam,
45    #[error("failed unmarshalling param in Heartbeat Chunk")]
46    ErrHeartbeatChunkUnmarshal,
47    #[error("unimplemented")]
48    ErrUnimplemented,
49    #[error("heartbeat Ack must have one param")]
50    ErrHeartbeatAckParams,
51    #[error("heartbeat Ack must have one param, and it should be a HeartbeatInfo")]
52    ErrHeartbeatAckNotHeartbeatInfo,
53    #[error("unable to marshal parameter for Heartbeat Ack")]
54    ErrHeartbeatAckMarshalParam,
55
56    #[error("raw is too small for error cause")]
57    ErrErrorCauseTooSmall,
58
59    #[error("unhandled ParamType")]
60    ErrParamTypeUnhandled,
61
62    #[error("unexpected ParamType")]
63    ErrParamTypeUnexpected,
64
65    #[error("param header too short")]
66    ErrParamHeaderTooShort,
67    #[error("param self reported length is shorter than header length")]
68    ErrParamHeaderSelfReportedLengthShorter,
69    #[error("param self reported length is longer than header length")]
70    ErrParamHeaderSelfReportedLengthLonger,
71    #[error("failed to parse param type")]
72    ErrParamHeaderParseFailed,
73
74    #[error("packet to short")]
75    ErrParamPacketTooShort,
76    #[error("outgoing SSN reset request parameter too short")]
77    ErrSsnResetRequestParamTooShort,
78    #[error("reconfig response parameter too short")]
79    ErrReconfigRespParamTooShort,
80    #[error("invalid algorithm type")]
81    ErrInvalidAlgorithmType,
82
83    #[error("failed to parse param type")]
84    ErrInitChunkParseParamTypeFailed,
85    #[error("failed unmarshalling param in Init Chunk")]
86    ErrInitChunkUnmarshalParam,
87    #[error("unable to marshal parameter for INIT/INITACK")]
88    ErrInitAckMarshalParam,
89
90    #[error("ChunkType is not of type INIT")]
91    ErrChunkTypeNotTypeInit,
92    #[error("chunk Value isn't long enough for mandatory parameters exp")]
93    ErrChunkValueNotLongEnough,
94    #[error("ChunkType of type INIT flags must be all 0")]
95    ErrChunkTypeInitFlagZero,
96    #[error("failed to unmarshal INIT body")]
97    ErrChunkTypeInitUnmarshalFailed,
98    #[error("failed marshaling INIT common data")]
99    ErrChunkTypeInitMarshalFailed,
100    #[error("ChunkType of type INIT ACK InitiateTag must not be 0")]
101    ErrChunkTypeInitInitateTagZero,
102    #[error("INIT ACK inbound stream request must be > 0")]
103    ErrInitInboundStreamRequestZero,
104    #[error("INIT ACK outbound stream request must be > 0")]
105    ErrInitOutboundStreamRequestZero,
106    #[error("INIT ACK Advertised Receiver Window Credit (a_rwnd) must be >= 1500")]
107    ErrInitAdvertisedReceiver1500,
108
109    #[error("packet is smaller than the header size")]
110    ErrChunkPayloadSmall,
111    #[error("ChunkType is not of type PayloadData")]
112    ErrChunkTypeNotPayloadData,
113    #[error("ChunkType is not of type Reconfig")]
114    ErrChunkTypeNotReconfig,
115    #[error("ChunkReconfig has invalid ParamA")]
116    ErrChunkReconfigInvalidParamA,
117
118    #[error("failed to parse param type")]
119    ErrChunkParseParamTypeFailed,
120    #[error("unable to marshal parameter A for reconfig")]
121    ErrChunkMarshalParamAReconfigFailed,
122    #[error("unable to marshal parameter B for reconfig")]
123    ErrChunkMarshalParamBReconfigFailed,
124
125    #[error("ChunkType is not of type SACK")]
126    ErrChunkTypeNotSack,
127    #[error("SACK Chunk size is not large enough to contain header")]
128    ErrSackSizeNotLargeEnoughInfo,
129
130    #[error("invalid chunk size")]
131    ErrInvalidChunkSize,
132    #[error("ChunkType is not of type SHUTDOWN")]
133    ErrChunkTypeNotShutdown,
134
135    #[error("ChunkType is not of type SHUTDOWN-ACK")]
136    ErrChunkTypeNotShutdownAck,
137    #[error("ChunkType is not of type SHUTDOWN-COMPLETE")]
138    ErrChunkTypeNotShutdownComplete,
139
140    #[error("raw is smaller than the minimum length for a SCTP packet")]
141    ErrPacketRawTooSmall,
142    #[error("unable to parse SCTP chunk, not enough data for complete header")]
143    ErrParseSctpChunkNotEnoughData,
144    #[error("failed to unmarshal, contains unknown chunk type")]
145    ErrUnmarshalUnknownChunkType,
146    #[error("checksum mismatch theirs")]
147    ErrChecksumMismatch,
148
149    #[error("unexpected chunk popped (unordered)")]
150    ErrUnexpectedChuckPoppedUnordered,
151    #[error("unexpected chunk popped (ordered)")]
152    ErrUnexpectedChuckPoppedOrdered,
153    #[error("unexpected q state (should've been selected)")]
154    ErrUnexpectedQState,
155    #[error("try again")]
156    ErrTryAgain,
157
158    #[error("abort chunk, with following errors")]
159    ErrChunk,
160    #[error("shutdown called in non-Established state")]
161    ErrShutdownNonEstablished,
162    #[error("association closed before connecting")]
163    ErrAssociationClosedBeforeConn,
164    #[error("association init failed")]
165    ErrAssociationInitFailed,
166    #[error("association handshake closed")]
167    ErrAssociationHandshakeClosed,
168    #[error("silently discard")]
169    ErrSilentlyDiscard,
170    #[error("the init not stored to send")]
171    ErrInitNotStoredToSend,
172    #[error("cookieEcho not stored to send")]
173    ErrCookieEchoNotStoredToSend,
174    #[error("sctp packet must not have a source port of 0")]
175    ErrSctpPacketSourcePortZero,
176    #[error("sctp packet must not have a destination port of 0")]
177    ErrSctpPacketDestinationPortZero,
178    #[error("init chunk must not be bundled with any other chunk")]
179    ErrInitChunkBundled,
180    #[error("init chunk expects a verification tag of 0 on the packet when out-of-the-blue")]
181    ErrInitChunkVerifyTagNotZero,
182    #[error("todo: handle Init when in state")]
183    ErrHandleInitState,
184    #[error("no cookie in InitAck")]
185    ErrInitAckNoCookie,
186    #[error("there already exists a stream with identifier")]
187    ErrStreamAlreadyExist,
188    #[error("Failed to create a stream with identifier")]
189    ErrStreamCreateFailed,
190    #[error("unable to be popped from inflight queue TSN")]
191    ErrInflightQueueTsnPop,
192    #[error("requested non-existent TSN")]
193    ErrTsnRequestNotExist,
194    #[error("sending reset packet in non-Established state")]
195    ErrResetPacketInStateNotExist,
196    #[error("unexpected parameter type")]
197    ErrParamterType,
198    #[error("sending payload data in non-Established state")]
199    ErrPayloadDataStateNotExist,
200    #[error("unhandled chunk type")]
201    ErrChunkTypeUnhandled,
202    #[error("handshake failed (INIT ACK)")]
203    ErrHandshakeInitAck,
204    #[error("handshake failed (COOKIE ECHO)")]
205    ErrHandshakeCookieEcho,
206
207    #[error("outbound packet larger than maximum message size")]
208    ErrOutboundPacketTooLarge,
209    #[error("Stream closed")]
210    ErrStreamClosed,
211    #[error("Short buffer to be filled")]
212    ErrShortBuffer,
213    #[error("Io EOF")]
214    ErrEof,
215    #[error("Invalid SystemTime")]
216    ErrInvalidSystemTime,
217    #[error("Net Conn read error")]
218    ErrNetConnReadError,
219    #[error("Max Data Channel ID")]
220    ErrMaxDataChannelID,
221
222    #[error("{0}")]
223    Other(String),
224}