All Downloads are FREE. Search and download functionalities are using the official Maven repository.

vendor.github.com.pion.sctp.param.go Maven / Gradle / Ivy

There is a newer version: 2.9.1
Show newest version
package sctp

import (
	"errors"
	"fmt"
)

type param interface {
	marshal() ([]byte, error)
	length() int
}

var errParamTypeUnhandled = errors.New("unhandled ParamType")

func buildParam(t paramType, rawParam []byte) (param, error) {
	switch t {
	case forwardTSNSupp:
		return (¶mForwardTSNSupported{}).unmarshal(rawParam)
	case supportedExt:
		return (¶mSupportedExtensions{}).unmarshal(rawParam)
	case ecnCapable:
		return (¶mECNCapable{}).unmarshal(rawParam)
	case random:
		return (¶mRandom{}).unmarshal(rawParam)
	case reqHMACAlgo:
		return (¶mRequestedHMACAlgorithm{}).unmarshal(rawParam)
	case chunkList:
		return (¶mChunkList{}).unmarshal(rawParam)
	case stateCookie:
		return (¶mStateCookie{}).unmarshal(rawParam)
	case heartbeatInfo:
		return (¶mHeartbeatInfo{}).unmarshal(rawParam)
	case outSSNResetReq:
		return (¶mOutgoingResetRequest{}).unmarshal(rawParam)
	case reconfigResp:
		return (¶mReconfigResponse{}).unmarshal(rawParam)
	default:
		return nil, fmt.Errorf("%w: %v", errParamTypeUnhandled, t)
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy