Debian Codegraph @

error_cause_protocol_violation.go

raw
1 // SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
2 // SPDX-License-Identifier: MIT
3
4 package sctp
5
6 import (
7 "errors"
8 "fmt"
9 )
10
11 /*
12 This error cause MAY be included in ABORT chunks that are sent
13 because an SCTP endpoint detects a protocol violation of the peer
14 that is not covered by the error causes described in Section 3.3.10.1
15 to Section 3.3.10.12. An implementation MAY provide additional
16 information specifying what kind of protocol violation has been
17 detected.
18
19 0 1 2 3
20 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
21 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
22 | Cause Code=13 | Cause Length=Variable |
23 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24 / Additional Information /
25 \ \
26 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27 */
28 type errorCauseProtocolViolation struct {
29 errorCauseHeader
30 additionalInformation []byte
31 }
32
33 // Abort chunk errors.
34 var (
35 ErrProtocolViolationUnmarshal = errors.New("unable to unmarshal Protocol Violation error")
36 )
37
38 func (e *errorCauseProtocolViolation) marshal() ([]byte, error) {
39 e.raw = e.additionalInformation
40
41 return e.errorCauseHeader.marshal()
42 }
43
44 func (e *errorCauseProtocolViolation) unmarshal(raw []byte) error {
45 err := e.errorCauseHeader.unmarshal(raw)
46 if err != nil {
47 return fmt.Errorf("%w: %v", ErrProtocolViolationUnmarshal, err) //nolint:errorlint
48 }
49
50 e.additionalInformation = e.raw
51
52 return nil
53 }
54
55 // String makes errorCauseProtocolViolation printable.
56 func (e *errorCauseProtocolViolation) String() string {
57 return fmt.Sprintf("%s: %s", e.errorCauseHeader, e.additionalInformation)
58 }