Siddarth Kumar 926f6a3c72 Revert "test: bump go-libp2p"
This reverts commit d0ca4447c6c5642830354740d045f453eb3e77e8.
2024-01-18 20:29:33 +00:00

41 lines
1.0 KiB
Go

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 (&paramForwardTSNSupported{}).unmarshal(rawParam)
case supportedExt:
return (&paramSupportedExtensions{}).unmarshal(rawParam)
case ecnCapable:
return (&paramECNCapable{}).unmarshal(rawParam)
case random:
return (&paramRandom{}).unmarshal(rawParam)
case reqHMACAlgo:
return (&paramRequestedHMACAlgorithm{}).unmarshal(rawParam)
case chunkList:
return (&paramChunkList{}).unmarshal(rawParam)
case stateCookie:
return (&paramStateCookie{}).unmarshal(rawParam)
case heartbeatInfo:
return (&paramHeartbeatInfo{}).unmarshal(rawParam)
case outSSNResetReq:
return (&paramOutgoingResetRequest{}).unmarshal(rawParam)
case reconfigResp:
return (&paramReconfigResponse{}).unmarshal(rawParam)
default:
return nil, fmt.Errorf("%w: %v", errParamTypeUnhandled, t)
}
}