param_supported_extensions.go 563 B

1234567891011121314151617181920212223242526272829
  1. package sctp
  2. type paramSupportedExtensions struct {
  3. paramHeader
  4. ChunkTypes []chunkType
  5. }
  6. func (s *paramSupportedExtensions) marshal() ([]byte, error) {
  7. s.typ = supportedExt
  8. s.raw = make([]byte, len(s.ChunkTypes))
  9. for i, c := range s.ChunkTypes {
  10. s.raw[i] = byte(c)
  11. }
  12. return s.paramHeader.marshal()
  13. }
  14. func (s *paramSupportedExtensions) unmarshal(raw []byte) (param, error) {
  15. err := s.paramHeader.unmarshal(raw)
  16. if err != nil {
  17. return nil, err
  18. }
  19. for _, t := range s.raw {
  20. s.ChunkTypes = append(s.ChunkTypes, chunkType(t))
  21. }
  22. return s, nil
  23. }