chunk_shutdown_complete.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package sctp
  2. import (
  3. "errors"
  4. "fmt"
  5. )
  6. /*
  7. chunkShutdownComplete represents an SCTP Chunk of type chunkShutdownComplete
  8. 0 1 2 3
  9. 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
  10. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  11. | Type = 14 |Reserved |T| Length = 4 |
  12. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  13. */
  14. type chunkShutdownComplete struct {
  15. chunkHeader
  16. }
  17. var errChunkTypeNotShutdownComplete = errors.New("ChunkType is not of type SHUTDOWN-COMPLETE")
  18. func (c *chunkShutdownComplete) unmarshal(raw []byte) error {
  19. if err := c.chunkHeader.unmarshal(raw); err != nil {
  20. return err
  21. }
  22. if c.typ != ctShutdownComplete {
  23. return fmt.Errorf("%w: actually is %s", errChunkTypeNotShutdownComplete, c.typ.String())
  24. }
  25. return nil
  26. }
  27. func (c *chunkShutdownComplete) marshal() ([]byte, error) {
  28. c.typ = ctShutdownComplete
  29. return c.chunkHeader.marshal()
  30. }
  31. func (c *chunkShutdownComplete) check() (abort bool, err error) {
  32. return false, nil
  33. }
  34. // String makes chunkShutdownComplete printable
  35. func (c *chunkShutdownComplete) String() string {
  36. return c.chunkHeader.String()
  37. }