Source File
chunk_heartbeat_ack.go
Belonging Package
github.com/pion/sctp
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage sctpimport ()/*chunkHeartbeatAck represents an SCTP Chunk of type HEARTBEAT ACKAn endpoint should send this chunk to its peer endpoint as a responseto a HEARTBEAT chunk (see Section 8.3). A HEARTBEAT ACK is alwayssent to the source IP address of the IP datagram containing theHEARTBEAT chunk to which this ack is responding.The parameter field contains a variable-length opaque data structure.0 1 2 30 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 = 5 | Chunk Flags | Heartbeat Ack Length |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| || Heartbeat Information TLV (Variable-Length) || |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Defined as a variable-length parameter using the format describedin Section 3.2.1, i.e.:Variable Parameters Status Type Value-------------------------------------------------------------Heartbeat Info Mandatory 1.*/type chunkHeartbeatAck struct {chunkHeaderparams []param}// Heartbeat ack chunk errors.var (ErrUnimplemented = errors.New("unimplemented")ErrHeartbeatAckParams = errors.New("heartbeat Ack must have one param")ErrHeartbeatAckNotHeartbeatInfo = errors.New("heartbeat Ack must have one param, and it should be a HeartbeatInfo")ErrHeartbeatAckMarshalParam = errors.New("unable to marshal parameter for Heartbeat Ack"))func ( *chunkHeartbeatAck) ([]byte) error {return ErrUnimplemented}func ( *chunkHeartbeatAck) () ([]byte, error) {if len(.params) != 1 {return nil, ErrHeartbeatAckParams}switch .params[0].(type) {case *paramHeartbeatInfo:// ParamHeartbeatInfo is validdefault:return nil, ErrHeartbeatAckNotHeartbeatInfo}:= make([]byte, 0)for , := range .params {, := .marshal()if != nil {return nil, fmt.Errorf("%w: %v", ErrHeartbeatAckMarshalParam, ) //nolint:errorlint}= append(, ...)// Chunks (including Type, Length, and Value fields) are padded out// by the sender with all zero bytes to be a multiple of 4 bytes// long. This padding MUST NOT be more than 3 bytes in total. The// Chunk Length value does not include terminating padding of the// chunk. *However, it does include padding of any variable-length// parameter except the last parameter in the chunk.* The receiver// MUST ignore the padding.if != len(.params)-1 {= padByte(, getPadding(len()))}}.chunkHeader.typ = ctHeartbeatAck.chunkHeader.raw =return .chunkHeader.marshal()}func ( *chunkHeartbeatAck) () ( bool, error) {return false, nil}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |