Source File
reqtrans.go
Belonging Package
github.com/pion/turn/v4/internal/proto
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage protoimport ()// Protocol is IANA assigned protocol number.type Protocol byteconst (// ProtoTCP is IANA assigned protocol number for TCP.ProtoTCP Protocol = 6// ProtoUDP is IANA assigned protocol number for UDP.ProtoUDP Protocol = 17)func ( Protocol) () string {switch {case ProtoTCP:return "TCP"case ProtoUDP:return "UDP"default:return strconv.Itoa(int())}}// RequestedTransport represents REQUESTED-TRANSPORT attribute.//// This attribute is used by the client to request a specific transport// protocol for the allocated transport address. RFC 5766 only allows the use of// code point 17 (User Datagram Protocol).//// RFC 5766 Section 14.7.type RequestedTransport struct {Protocol Protocol}func ( RequestedTransport) () string {return "protocol: " + .Protocol.String()}const requestedTransportSize = 4// AddTo adds REQUESTED-TRANSPORT to message.func ( RequestedTransport) ( *stun.Message) error {:= make([]byte, requestedTransportSize)[0] = byte(.Protocol)// b[1:4] is RFFU = 0.// The RFFU field MUST be set to zero on transmission and MUST be// ignored on reception. It is reserved for future uses..Add(stun.AttrRequestedTransport, )return nil}// GetFrom decodes REQUESTED-TRANSPORT from message.func ( *RequestedTransport) ( *stun.Message) error {, := .Get(stun.AttrRequestedTransport)if != nil {return}if = stun.CheckSize(stun.AttrRequestedTransport, len(), requestedTransportSize); != nil {return}.Protocol = Protocol([0])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. |