File: param_chunk_list.go

package info (click to toggle)
golang-github-pion-sctp 1.8.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, sid, trixie
  • size: 888 kB
  • sloc: makefile: 13
file content (28 lines) | stat: -rw-r--r-- 529 bytes parent folder | download
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
package sctp

type paramChunkList struct {
	paramHeader
	chunkTypes []chunkType
}

func (c *paramChunkList) marshal() ([]byte, error) {
	c.typ = chunkList
	c.raw = make([]byte, len(c.chunkTypes))
	for i, t := range c.chunkTypes {
		c.raw[i] = byte(t)
	}

	return c.paramHeader.marshal()
}

func (c *paramChunkList) unmarshal(raw []byte) (param, error) {
	err := c.paramHeader.unmarshal(raw)
	if err != nil {
		return nil, err
	}
	for _, t := range c.raw {
		c.chunkTypes = append(c.chunkTypes, chunkType(t))
	}

	return c, nil
}