Source File
connection_id.go
Belonging Package
github.com/pion/dtls/v3/pkg/protocol/extension
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage extensionimport ()// ConnectionID is a DTLS extension that provides an alternative to IP address// and port for session association.//// https://tools.ietf.org/html/rfc9146type ConnectionID struct {// A zero-length connection ID indicates for a client or server that// negotiated connection IDs from the peer will be sent but there is no need// to respond with oneCID []byte // variable length}// TypeValue returns the extension TypeValue.func ( ConnectionID) () TypeValue {return ConnectionIDTypeValue}// Marshal encodes the extension.func ( *ConnectionID) () ([]byte, error) {var cryptobyte.Builder.AddUint16(uint16(.TypeValue())).AddUint16LengthPrefixed(func( *cryptobyte.Builder) {.AddUint8LengthPrefixed(func( *cryptobyte.Builder) {.AddBytes(.CID)})})return .Bytes()}// Unmarshal populates the extension from encoded data.func ( *ConnectionID) ( []byte) error {:= cryptobyte.String()var uint16.ReadUint16(&)if TypeValue() != .TypeValue() {return errInvalidExtensionType}var cryptobyte.String.ReadUint16LengthPrefixed(&)var cryptobyte.Stringif !.ReadUint8LengthPrefixed(&) {return errInvalidCIDFormat}.CID = make([]byte, len())if !.CopyBytes(.CID) {return errInvalidCIDFormat}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. |