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