forked from quic-go/quic-go
set the default value for the ack_delay_exponent, if it is not sent
This commit is contained in:
@@ -108,6 +108,14 @@ var _ = Describe("Transport Parameters", func() {
|
||||
Expect(b.Len()).To(Equal(defaultLen + 2 /* parameter ID */ + 2 /* length field */ + 1 /* value */))
|
||||
})
|
||||
|
||||
It("sets the default value for the ack_delay_exponent, when no value was sent", func() {
|
||||
b := &bytes.Buffer{}
|
||||
(&TransportParameters{AckDelayExponent: protocol.DefaultAckDelayExponent}).marshal(b)
|
||||
p := &TransportParameters{}
|
||||
Expect(p.unmarshal(b.Bytes(), protocol.PerspectiveServer)).To(Succeed())
|
||||
Expect(p.AckDelayExponent).To(BeEquivalentTo(protocol.DefaultAckDelayExponent))
|
||||
})
|
||||
|
||||
It("errors when the varint value has the wrong length", func() {
|
||||
b := &bytes.Buffer{}
|
||||
utils.BigEndian.WriteUint16(b, uint16(initialMaxStreamDataBidiLocalParameterID))
|
||||
|
||||
@@ -54,6 +54,8 @@ func (p *TransportParameters) unmarshal(data []byte, sentBy protocol.Perspective
|
||||
// needed to check that every parameter is only sent at most once
|
||||
var parameterIDs []transportParameterID
|
||||
|
||||
var readAckDelayExponent bool
|
||||
|
||||
r := bytes.NewReader(data)
|
||||
for r.Len() >= 4 {
|
||||
paramIDInt, _ := utils.BigEndian.ReadUint16(r)
|
||||
@@ -61,6 +63,9 @@ func (p *TransportParameters) unmarshal(data []byte, sentBy protocol.Perspective
|
||||
paramLen, _ := utils.BigEndian.ReadUint16(r)
|
||||
parameterIDs = append(parameterIDs, paramID)
|
||||
switch paramID {
|
||||
case ackDelayExponentParameterID:
|
||||
readAckDelayExponent = true
|
||||
fallthrough
|
||||
case initialMaxStreamDataBidiLocalParameterID,
|
||||
initialMaxStreamDataBidiRemoteParameterID,
|
||||
initialMaxStreamDataUniParameterID,
|
||||
@@ -68,8 +73,7 @@ func (p *TransportParameters) unmarshal(data []byte, sentBy protocol.Perspective
|
||||
initialMaxStreamsBidiParameterID,
|
||||
initialMaxStreamsUniParameterID,
|
||||
idleTimeoutParameterID,
|
||||
maxPacketSizeParameterID,
|
||||
ackDelayExponentParameterID:
|
||||
maxPacketSizeParameterID:
|
||||
if err := p.readNumericTransportParameter(r, paramID, int(paramLen)); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -104,6 +108,10 @@ func (p *TransportParameters) unmarshal(data []byte, sentBy protocol.Perspective
|
||||
}
|
||||
}
|
||||
|
||||
if !readAckDelayExponent {
|
||||
p.AckDelayExponent = protocol.DefaultAckDelayExponent
|
||||
}
|
||||
|
||||
// check that every transport parameter was sent at most once
|
||||
sort.Slice(parameterIDs, func(i, j int) bool { return parameterIDs[i] < parameterIDs[j] })
|
||||
for i := 0; i < len(parameterIDs)-1; i++ {
|
||||
|
||||
Reference in New Issue
Block a user