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