| 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 |
chunkCookieAck represents an SCTP Chunk of type chunkCookieAck |
| 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 = 11 |Chunk Flags | Length = 4 | |
| 18 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 19 |
*/ |
| 20 |
type chunkCookieAck struct { |
| 21 |
chunkHeader |
| 22 |
} |
| 23 |
|
| 24 |
// Cookie ack chunk errors. |
| 25 |
var ( |
| 26 |
ErrChunkTypeNotCookieAck = errors.New("ChunkType is not of type COOKIEACK") |
| 27 |
) |
| 28 |
|
| 29 |
func (c *chunkCookieAck) unmarshal(raw []byte) error { |
| 30 |
if err := c.chunkHeader.unmarshal(raw); err != nil { |
| 31 |
return err |
| 32 |
} |
| 33 |
|
| 34 |
if c.typ != ctCookieAck { |
| 35 |
return fmt.Errorf("%w: actually is %s", ErrChunkTypeNotCookieAck, c.typ.String()) |
| 36 |
} |
| 37 |
|
| 38 |
return nil |
| 39 |
} |
| 40 |
|
| 41 |
func (c *chunkCookieAck) marshal() ([]byte, error) { |
| 42 |
c.chunkHeader.typ = ctCookieAck |
| 43 |
|
| 44 |
return c.chunkHeader.marshal() |
| 45 |
} |
| 46 |
|
| 47 |
func (c *chunkCookieAck) check() (abort bool, err error) { |
| 48 |
return false, nil |
| 49 |
} |
| 50 |
|
| 51 |
// String makes chunkCookieAck printable. |
| 52 |
func (c *chunkCookieAck) String() string { |
| 53 |
return c.chunkHeader.String() |
| 54 |
} |