summaryrefslogtreecommitdiff
path: root/vendor/github.com/pion/sctp/param_chunk_list.go
blob: 4ea484c9f3115a636218a7cdfbf7af1f610337b7 (plain)
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
}