2022-03-10 09:44:48 +00:00
|
|
|
package sctp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
/*
|
|
|
|
chunkCookieAck represents an SCTP Chunk of type chunkCookieAck
|
|
|
|
|
2024-01-03 21:57:33 +00:00
|
|
|
0 1 2 3
|
|
|
|
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
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
| Type = 11 |Chunk Flags | Length = 4 |
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
2022-03-10 09:44:48 +00:00
|
|
|
*/
|
|
|
|
type chunkCookieAck struct {
|
|
|
|
chunkHeader
|
|
|
|
}
|
|
|
|
|
2024-01-03 21:57:33 +00:00
|
|
|
// Cookie ack chunk errors
|
|
|
|
var (
|
|
|
|
ErrChunkTypeNotCookieAck = errors.New("ChunkType is not of type COOKIEACK")
|
|
|
|
)
|
2022-03-10 09:44:48 +00:00
|
|
|
|
|
|
|
func (c *chunkCookieAck) unmarshal(raw []byte) error {
|
|
|
|
if err := c.chunkHeader.unmarshal(raw); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if c.typ != ctCookieAck {
|
2024-01-03 21:57:33 +00:00
|
|
|
return fmt.Errorf("%w: actually is %s", ErrChunkTypeNotCookieAck, c.typ.String())
|
2022-03-10 09:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *chunkCookieAck) marshal() ([]byte, error) {
|
|
|
|
c.chunkHeader.typ = ctCookieAck
|
|
|
|
return c.chunkHeader.marshal()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *chunkCookieAck) check() (abort bool, err error) {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// String makes chunkCookieAck printable
|
|
|
|
func (c *chunkCookieAck) String() string {
|
|
|
|
return c.chunkHeader.String()
|
|
|
|
}
|