Source File
header.go
Belonging Package
github.com/pion/dtls/v2/pkg/protocol/handshake
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage handshakeimport ()// HeaderLength msg_len for Handshake messages assumes an extra// 12 bytes for sequence, fragment and version information vs TLSconst HeaderLength = 12// Header is the static first 12 bytes of each RecordLayer// of type Handshake. These fields allow us to support message loss, reordering, and// message fragmentation,//// https://tools.ietf.org/html/rfc6347#section-4.2.2type Header struct {Type TypeLength uint32 // uint24 in specMessageSequence uint16FragmentOffset uint32 // uint24 in specFragmentLength uint32 // uint24 in spec}// Marshal encodes the Headerfunc ( *Header) () ([]byte, error) {:= make([]byte, HeaderLength)[0] = byte(.Type)util.PutBigEndianUint24([1:], .Length)binary.BigEndian.PutUint16([4:], .MessageSequence)util.PutBigEndianUint24([6:], .FragmentOffset)util.PutBigEndianUint24([9:], .FragmentLength)return , nil}// Unmarshal populates the header from encoded datafunc ( *Header) ( []byte) error {if len() < HeaderLength {return errBufferTooSmall}.Type = Type([0]).Length = util.BigEndianUint24([1:]).MessageSequence = binary.BigEndian.Uint16([4:]).FragmentOffset = util.BigEndianUint24([6:]).FragmentLength = util.BigEndianUint24([9:])return 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. |