Source File
error_cause.go
Belonging Package
github.com/pion/sctp
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage sctpimport ()// errorCauseCode is a cause code that appears in either a ERROR or ABORT chunk.type errorCauseCode uint16type errorCause interface {unmarshal([]byte) errormarshal() ([]byte, error)length() uint16String() stringerrorCauseCode() errorCauseCode}// Error and abort chunk errors.var (ErrBuildErrorCaseHandle = errors.New("BuildErrorCause does not handle"))// buildErrorCause delegates the building of a error cause from raw bytes to the correct structure.func buildErrorCause( []byte) (errorCause, error) {var errorCause:= errorCauseCode(binary.BigEndian.Uint16([0:]))switch {case invalidMandatoryParameter:= &errorCauseInvalidMandatoryParameter{}case unrecognizedChunkType:= &errorCauseUnrecognizedChunkType{}case protocolViolation:= &errorCauseProtocolViolation{}case userInitiatedAbort:= &errorCauseUserInitiatedAbort{}default:return nil, fmt.Errorf("%w: %s", ErrBuildErrorCaseHandle, .String())}if := .unmarshal(); != nil {return nil,}return , nil}const (invalidStreamIdentifier errorCauseCode = 1missingMandatoryParameter errorCauseCode = 2staleCookieError errorCauseCode = 3outOfResource errorCauseCode = 4unresolvableAddress errorCauseCode = 5unrecognizedChunkType errorCauseCode = 6invalidMandatoryParameter errorCauseCode = 7unrecognizedParameters errorCauseCode = 8noUserData errorCauseCode = 9cookieReceivedWhileShuttingDown errorCauseCode = 10restartOfAnAssociationWithNewAddresses errorCauseCode = 11userInitiatedAbort errorCauseCode = 12protocolViolation errorCauseCode = 13)func ( errorCauseCode) () string { //nolint:cyclopswitch {case invalidStreamIdentifier:return "Invalid Stream Identifier"case missingMandatoryParameter:return "Missing Mandatory Parameter"case staleCookieError:return "Stale Cookie Error"case outOfResource:return "Out Of Resource"case unresolvableAddress:return "Unresolvable IP"case unrecognizedChunkType:return "Unrecognized Chunk Type"case invalidMandatoryParameter:return "Invalid Mandatory Parameter"case unrecognizedParameters:return "Unrecognized Parameters"case noUserData:return "No User Data"case cookieReceivedWhileShuttingDown:return "Cookie Received While Shutting Down"case restartOfAnAssociationWithNewAddresses:return "Restart Of An Association With New Addresses"case userInitiatedAbort:return "User Initiated Abort"case protocolViolation:return "Protocol Violation"default:return fmt.Sprintf("Unknown CauseCode: %d", )}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |