Debian Codegraph @

chunk_cookie_echo.go

raw
1 // SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
2 // SPDX-License-Identifier: MIT
3
4 package sctp
5
6 import (
7 "errors"
8 "fmt"
9 )
10
11 /*
12 CookieEcho represents an SCTP Chunk of type CookieEcho
13
14 0 1 2 3
15 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
16 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
17 | Type = 10 |Chunk Flags | Length |
18 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
19 | Cookie |
20 | |
21 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
22 */
23 type chunkCookieEcho struct {
24 chunkHeader
25 cookie []byte
26 }
27
28 // Cookie echo chunk errors.
29 var (
30 ErrChunkTypeNotCookieEcho = errors.New("ChunkType is not of type COOKIEECHO")
31 )
32
33 func (c *chunkCookieEcho) unmarshal(raw []byte) error {
34 if err := c.chunkHeader.unmarshal(raw); err != nil {
35 return err
36 }
37
38 if c.typ != ctCookieEcho {
39 return fmt.Errorf("%w: actually is %s", ErrChunkTypeNotCookieEcho, c.typ.String())
40 }
41 c.cookie = c.raw
42
43 return nil
44 }
45
46 func (c *chunkCookieEcho) marshal() ([]byte, error) {
47 c.chunkHeader.typ = ctCookieEcho
48 c.chunkHeader.raw = c.cookie
49
50 return c.chunkHeader.marshal()
51 }
52
53 func (c *chunkCookieEcho) check() (abort bool, err error) {
54 return false, nil
55 }