1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

TEST: Upgrade pion to v3.2.9. (#3567)

------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
This commit is contained in:
Winlin 2023-06-05 11:25:04 +08:00 committed by GitHub
parent 104cf14d68
commit df854339ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1383 changed files with 118469 additions and 41421 deletions

View file

@ -3,9 +3,8 @@ package sctp
import (
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
"github.com/pkg/errors"
)
type paramHeader struct {
@ -18,6 +17,14 @@ const (
paramHeaderLength = 4
)
// Parameter header parse errors
var (
ErrParamHeaderTooShort = errors.New("param header too short")
ErrParamHeaderSelfReportedLengthShorter = errors.New("param self reported length is shorter than header length")
ErrParamHeaderSelfReportedLengthLonger = errors.New("param self reported length is longer than header length")
ErrParamHeaderParseFailed = errors.New("failed to parse param type")
)
func (p *paramHeader) marshal() ([]byte, error) {
paramLengthPlusHeader := paramHeaderLength + len(p.raw)
@ -31,20 +38,20 @@ func (p *paramHeader) marshal() ([]byte, error) {
func (p *paramHeader) unmarshal(raw []byte) error {
if len(raw) < paramHeaderLength {
return errors.New("param header too short")
return ErrParamHeaderTooShort
}
paramLengthPlusHeader := binary.BigEndian.Uint16(raw[2:])
if int(paramLengthPlusHeader) < paramHeaderLength {
return errors.Errorf("param self reported length (%d) smaller than header length (%d)", int(paramLengthPlusHeader), paramHeaderLength)
return fmt.Errorf("%w: param self reported length (%d) shorter than header length (%d)", ErrParamHeaderSelfReportedLengthShorter, int(paramLengthPlusHeader), paramHeaderLength)
}
if len(raw) < int(paramLengthPlusHeader) {
return errors.Errorf("param length (%d) shorter than its self reported length (%d)", len(raw), int(paramLengthPlusHeader))
return fmt.Errorf("%w: param length (%d) shorter than its self reported length (%d)", ErrParamHeaderSelfReportedLengthLonger, len(raw), int(paramLengthPlusHeader))
}
typ, err := parseParamType(raw[0:])
if err != nil {
return errors.Wrap(err, "failed to parse param type")
return fmt.Errorf("%w: %v", ErrParamHeaderParseFailed, err) //nolint:errorlint
}
p.typ = typ
p.raw = raw[paramHeaderLength:paramLengthPlusHeader]