status-go/vendor/github.com/pion/sctp/chunk_shutdown_complete.go

54 lines
1.3 KiB
Go
Raw Normal View History

2024-06-05 20:10:03 +00:00
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
2022-03-10 09:44:48 +00:00
package sctp
import (
"errors"
"fmt"
)
/*
chunkShutdownComplete represents an SCTP Chunk of type chunkShutdownComplete
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 14 |Reserved |T| Length = 4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
type chunkShutdownComplete struct {
chunkHeader
}
2024-05-15 23:15:00 +00:00
// Shutdown complete chunk errors
var (
ErrChunkTypeNotShutdownComplete = errors.New("ChunkType is not of type SHUTDOWN-COMPLETE")
)
2022-03-10 09:44:48 +00:00
func (c *chunkShutdownComplete) unmarshal(raw []byte) error {
if err := c.chunkHeader.unmarshal(raw); err != nil {
return err
}
if c.typ != ctShutdownComplete {
2024-05-15 23:15:00 +00:00
return fmt.Errorf("%w: actually is %s", ErrChunkTypeNotShutdownComplete, c.typ.String())
2022-03-10 09:44:48 +00:00
}
return nil
}
func (c *chunkShutdownComplete) marshal() ([]byte, error) {
c.typ = ctShutdownComplete
return c.chunkHeader.marshal()
}
func (c *chunkShutdownComplete) check() (abort bool, err error) {
return false, nil
}
// String makes chunkShutdownComplete printable
func (c *chunkShutdownComplete) String() string {
return c.chunkHeader.String()
}