Source File
error_cause_header.go
Belonging Package
github.com/pion/sctp
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage sctpimport ()// errorCauseHeader represents the shared header that is shared by all error causes.type errorCauseHeader struct {code errorCauseCodelen uint16raw []byte}const (errorCauseHeaderLength = 4)// ErrInvalidSCTPChunk is returned when an SCTP chunk is invalid.var ErrInvalidSCTPChunk = errors.New("invalid SCTP chunk")func ( *errorCauseHeader) () ([]byte, error) {.len = uint16(len(.raw)) + uint16(errorCauseHeaderLength) //nolint:gosec // G115:= make([]byte, .len)binary.BigEndian.PutUint16([0:], uint16(.code))binary.BigEndian.PutUint16([2:], .len)copy([errorCauseHeaderLength:], .raw)return , nil}func ( *errorCauseHeader) ( []byte) error {.code = errorCauseCode(binary.BigEndian.Uint16([0:])).len = binary.BigEndian.Uint16([2:])if .len < errorCauseHeaderLength || int(.len) > len() {return ErrInvalidSCTPChunk}:= .len - errorCauseHeaderLength.raw = [errorCauseHeaderLength : errorCauseHeaderLength+]return nil}func ( *errorCauseHeader) () uint16 {return .len}func ( *errorCauseHeader) () errorCauseCode {return .code}// String makes errorCauseHeader printable.func ( errorCauseHeader) () string {return .code.String()}
![]() |
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. |