use the TRANSPORT_PARAMETER_ERROR

This commit is contained in:
Marten Seemann
2019-10-25 06:47:26 +07:00
parent 82873477ed
commit 4834159210
4 changed files with 25 additions and 16 deletions

View File

@@ -10,6 +10,8 @@ import (
"sort"
"time"
"github.com/lucas-clemente/quic-go/internal/qerr"
"github.com/lucas-clemente/quic-go/internal/protocol"
"github.com/lucas-clemente/quic-go/internal/utils"
)
@@ -61,6 +63,13 @@ type TransportParameters struct {
// Unmarshal the transport parameters
func (p *TransportParameters) Unmarshal(data []byte, sentBy protocol.Perspective) error {
if err := p.unmarshal(data, sentBy); err != nil {
return qerr.Error(qerr.TransportParameterError, err.Error())
}
return nil
}
func (p *TransportParameters) unmarshal(data []byte, sentBy protocol.Perspective) error {
if len(data) < 2 {
return errors.New("transport parameter data too short")
}