mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 13:17:36 +03:00
remove PacketNumberLen from Frame interface Write method
This commit is contained in:
parent
060df6be7d
commit
aaf4b0ae9e
18 changed files with 59 additions and 59 deletions
|
@ -21,7 +21,7 @@ type AckFrame struct {
|
|||
}
|
||||
|
||||
// Write writes an ACK frame.
|
||||
func (f *AckFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error {
|
||||
func (f *AckFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, version protocol.VersionNumber) error {
|
||||
typeByte := uint8(0x40 | 0x0C)
|
||||
|
||||
if f.HasNACK() {
|
||||
|
|
|
@ -249,7 +249,7 @@ var _ = Describe("AckFrame", func() {
|
|||
Entropy: 2,
|
||||
LargestObserved: 1,
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frame.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b.Bytes()).To(Equal([]byte{0x4c, 0x02, 0x01, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}))
|
||||
})
|
||||
|
@ -260,7 +260,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 4,
|
||||
NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frame.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
missingPacketBytes := b.Bytes()[b.Len()-8:]
|
||||
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
|
||||
|
@ -276,7 +276,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 4,
|
||||
NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 31)
|
||||
err := frame.Write(b, 1, 31)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
missingPacketBytes := b.Bytes()[b.Len()-9:]
|
||||
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
|
||||
|
@ -295,7 +295,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 7,
|
||||
NackRanges: []NackRange{nackRange1, nackRange2},
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frame.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
|
||||
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
|
||||
|
@ -316,7 +316,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 258,
|
||||
NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 257}},
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frame.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
missingPacketBytes := b.Bytes()[b.Len()-(1+7):]
|
||||
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
|
||||
|
@ -330,7 +330,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 302,
|
||||
NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 301}},
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frame.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
|
||||
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
|
||||
|
@ -346,7 +346,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 259,
|
||||
NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 258}},
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frame.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
|
||||
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
|
||||
|
@ -362,7 +362,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 603,
|
||||
NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 601}},
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frame.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
missingPacketBytes := b.Bytes()[b.Len()-(1+3*7):]
|
||||
Expect(missingPacketBytes[0]).To(Equal(uint8(3))) // numRanges
|
||||
|
@ -382,7 +382,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 655,
|
||||
NackRanges: []NackRange{nackRange2, nackRange1},
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frame.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
missingPacketBytes := b.Bytes()[b.Len()-(1+4*7):]
|
||||
Expect(missingPacketBytes[0]).To(Equal(uint8(4))) // numRanges
|
||||
|
@ -403,7 +403,7 @@ var _ = Describe("AckFrame", func() {
|
|||
Entropy: 2,
|
||||
LargestObserved: 1,
|
||||
}
|
||||
f.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
f.Write(b, 1, 2)
|
||||
Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len())))
|
||||
})
|
||||
|
||||
|
@ -413,7 +413,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 4,
|
||||
NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
||||
}
|
||||
err := f.Write(b, 1, protocol.PacketNumberLen6, 31)
|
||||
err := f.Write(b, 1, 31)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len())))
|
||||
})
|
||||
|
@ -431,7 +431,7 @@ var _ = Describe("AckFrame", func() {
|
|||
Entropy: 0xDE,
|
||||
LargestObserved: 6789,
|
||||
}
|
||||
err := frameOrig.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frameOrig.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
frame, err := ParseAckFrame(bytes.NewReader(b.Bytes()), 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
@ -449,7 +449,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 15,
|
||||
NackRanges: nackRanges,
|
||||
}
|
||||
err := frameOrig.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frameOrig.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
r := bytes.NewReader(b.Bytes())
|
||||
frame, err := ParseAckFrame(r, 32)
|
||||
|
@ -469,7 +469,7 @@ var _ = Describe("AckFrame", func() {
|
|||
LargestObserved: 1600,
|
||||
NackRanges: nackRanges,
|
||||
}
|
||||
err := frameOrig.Write(b, 1, protocol.PacketNumberLen6, 32)
|
||||
err := frameOrig.Write(b, 1, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
r := bytes.NewReader(b.Bytes())
|
||||
frame, err := ParseAckFrame(r, 32)
|
||||
|
|
|
@ -13,7 +13,7 @@ type BlockedFrame struct {
|
|||
}
|
||||
|
||||
//Write writes a RST_STREAM frame
|
||||
func (f *BlockedFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error {
|
||||
func (f *BlockedFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, version protocol.VersionNumber) error {
|
||||
b.WriteByte(0x05)
|
||||
|
||||
if f.StreamID == 0 {
|
||||
|
|
|
@ -22,7 +22,7 @@ var _ = Describe("BlockedFrame", func() {
|
|||
It("writes a sample frame", func() {
|
||||
b := &bytes.Buffer{}
|
||||
frame := BlockedFrame{StreamID: 0x1337}
|
||||
frame.Write(b, 10, protocol.PacketNumberLen6, 0)
|
||||
frame.Write(b, 10, 0)
|
||||
Expect(b.Bytes()).To(Equal([]byte{0x05, 0x37, 0x13, 0x0, 0x0}))
|
||||
})
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ func (f *ConnectionCloseFrame) MinLength() protocol.ByteCount {
|
|||
}
|
||||
|
||||
// Write writes an CONNECTION_CLOSE frame.
|
||||
func (f *ConnectionCloseFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error {
|
||||
func (f *ConnectionCloseFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, version protocol.VersionNumber) error {
|
||||
b.WriteByte(0x02)
|
||||
utils.WriteUint32(b, uint32(f.ErrorCode))
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ var _ = Describe("ConnectionCloseFrame", func() {
|
|||
frame := &ConnectionCloseFrame{
|
||||
ErrorCode: 0xDEADBEEF,
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
err := frame.Write(b, 1, 0)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b.Len()).To(Equal(1 + 2 + 4))
|
||||
Expect(b.Bytes()).To(Equal([]byte{0x02, 0xEF, 0xBE, 0xAD, 0xDE, 0x00, 0x00}))
|
||||
|
@ -47,7 +47,7 @@ var _ = Describe("ConnectionCloseFrame", func() {
|
|||
ErrorCode: 0xDEADBEEF,
|
||||
ReasonPhrase: "foobar",
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
err := frame.Write(b, 1, 0)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b.Len()).To(Equal(1 + 2 + 4 + len(frame.ReasonPhrase)))
|
||||
Expect(b.Bytes()[:5]).To(Equal([]byte{0x02, 0xEF, 0xBE, 0xAD, 0xDE}))
|
||||
|
@ -67,7 +67,7 @@ var _ = Describe("ConnectionCloseFrame", func() {
|
|||
ErrorCode: 0xDEADBEEF,
|
||||
ReasonPhrase: reasonPhrase,
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
err := frame.Write(b, 1, 0)
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
|
||||
|
@ -77,7 +77,7 @@ var _ = Describe("ConnectionCloseFrame", func() {
|
|||
ErrorCode: 0xDEADBEEF,
|
||||
ReasonPhrase: "foobar",
|
||||
}
|
||||
f.Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
f.Write(b, 1, 0)
|
||||
Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len())))
|
||||
})
|
||||
})
|
||||
|
@ -88,7 +88,7 @@ var _ = Describe("ConnectionCloseFrame", func() {
|
|||
ErrorCode: 0xDEADBEEF,
|
||||
ReasonPhrase: "Lorem ipsum dolor sit amet.",
|
||||
}
|
||||
err := frame.Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
err := frame.Write(b, 1, 0)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
readframe, err := ParseConnectionCloseFrame(bytes.NewReader(b.Bytes()))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
|
|
@ -8,6 +8,6 @@ import (
|
|||
|
||||
// A Frame in QUIC
|
||||
type Frame interface {
|
||||
Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error
|
||||
Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, version protocol.VersionNumber) error
|
||||
MinLength() protocol.ByteCount
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ func ParsePingFrame(r *bytes.Reader) (*PingFrame, error) {
|
|||
return frame, nil
|
||||
}
|
||||
|
||||
func (f *PingFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error {
|
||||
func (f *PingFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, version protocol.VersionNumber) error {
|
||||
typeByte := uint8(0x07)
|
||||
b.WriteByte(typeByte)
|
||||
return nil
|
||||
|
|
|
@ -22,7 +22,7 @@ var _ = Describe("PingFrame", func() {
|
|||
It("writes a sample frame", func() {
|
||||
b := &bytes.Buffer{}
|
||||
frame := PingFrame{}
|
||||
frame.Write(b, 10, protocol.PacketNumberLen6, 0)
|
||||
frame.Write(b, 10, 0)
|
||||
Expect(b.Bytes()).To(Equal([]byte{0x07}))
|
||||
})
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ type RstStreamFrame struct {
|
|||
}
|
||||
|
||||
//Write writes a RST_STREAM frame
|
||||
func (f *RstStreamFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error {
|
||||
func (f *RstStreamFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, version protocol.VersionNumber) error {
|
||||
panic("RstStreamFrame: Write not yet implemented")
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ type StopWaitingFrame struct {
|
|||
LeastUnacked protocol.PacketNumber
|
||||
}
|
||||
|
||||
func (f *StopWaitingFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error {
|
||||
func (f *StopWaitingFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, version protocol.VersionNumber) error {
|
||||
// packetNumber is the packet number of the packet that this StopWaitingFrame will be sent with
|
||||
typeByte := uint8(0x06)
|
||||
b.WriteByte(typeByte)
|
||||
|
|
|
@ -34,7 +34,7 @@ var _ = Describe("StopWaitingFrame", func() {
|
|||
LeastUnacked: 10,
|
||||
Entropy: 0xE,
|
||||
}
|
||||
frame.Write(b, packetNumber, protocol.PacketNumberLen6, 0)
|
||||
frame.Write(b, packetNumber, 0)
|
||||
Expect(b.Bytes()[0]).To(Equal(uint8(0x06)))
|
||||
// todo: check more
|
||||
})
|
||||
|
@ -48,7 +48,7 @@ var _ = Describe("StopWaitingFrame", func() {
|
|||
Entropy: 0xE,
|
||||
}
|
||||
b := &bytes.Buffer{}
|
||||
frame.Write(b, packetNumber, protocol.PacketNumberLen6, 0)
|
||||
frame.Write(b, packetNumber, 0)
|
||||
readframe, err := ParseStopWaitingFrame(bytes.NewReader(b.Bytes()), packetNumber, 6)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(readframe.Entropy).To(Equal(frame.Entropy))
|
||||
|
|
|
@ -78,7 +78,7 @@ func ParseStreamFrame(r *bytes.Reader) (*StreamFrame, error) {
|
|||
}
|
||||
|
||||
// WriteStreamFrame writes a stream frame.
|
||||
func (f *StreamFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error {
|
||||
func (f *StreamFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, version protocol.VersionNumber) error {
|
||||
typeByte := uint8(0x80) // sets the leftmost bit to 1
|
||||
|
||||
if f.FinBit {
|
||||
|
|
|
@ -40,7 +40,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
StreamID: 1,
|
||||
Data: []byte("foobar"),
|
||||
DataLenPresent: true,
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()).To(Equal([]byte{0xa0, 0x1, 0x06, 0x00, 'f', 'o', 'o', 'b', 'a', 'r'}))
|
||||
})
|
||||
|
||||
|
@ -51,7 +51,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
Data: []byte("f"),
|
||||
Offset: 0,
|
||||
}
|
||||
f.Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
f.Write(b, 1, 0)
|
||||
Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len())))
|
||||
})
|
||||
|
||||
|
@ -62,7 +62,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
Data: []byte("f"),
|
||||
Offset: 0xDEADBEEFCAFE,
|
||||
}
|
||||
f.Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
f.Write(b, 1, 0)
|
||||
Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len())))
|
||||
})
|
||||
|
||||
|
@ -76,7 +76,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
DataLenPresent: true,
|
||||
Offset: 0,
|
||||
}
|
||||
f.Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
f.Write(b, 1, 0)
|
||||
headerLength := f.MinLength() - 1
|
||||
Expect(b.Bytes()[0] & 0x20).To(Equal(uint8(0x20)))
|
||||
Expect(b.Bytes()[headerLength-2 : headerLength]).To(Equal([]byte{0x37, 0x13}))
|
||||
|
@ -91,7 +91,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
DataLenPresent: false,
|
||||
Offset: 0,
|
||||
}
|
||||
f.Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
f.Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x20).To(Equal(uint8(0)))
|
||||
Expect(b.Bytes()[1 : b.Len()-dataLen]).ToNot(ContainSubstring(string([]byte{0x37, 0x13})))
|
||||
minLength := f.MinLength()
|
||||
|
@ -119,7 +119,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
StreamID: 1,
|
||||
Data: []byte("foobar"),
|
||||
Offset: 0,
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x0)))
|
||||
})
|
||||
|
||||
|
@ -129,7 +129,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
StreamID: 1,
|
||||
Data: []byte("foobar"),
|
||||
Offset: 0x1337,
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x1 << 2)))
|
||||
Expect(b.Bytes()[2:4]).To(Equal([]byte{0x37, 0x13}))
|
||||
})
|
||||
|
@ -140,7 +140,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
StreamID: 1,
|
||||
Data: []byte("foobar"),
|
||||
Offset: 0x13CAFE,
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x2 << 2)))
|
||||
Expect(b.Bytes()[2:5]).To(Equal([]byte{0xFE, 0xCA, 0x13}))
|
||||
})
|
||||
|
@ -151,7 +151,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
StreamID: 1,
|
||||
Data: []byte("foobar"),
|
||||
Offset: 0xDEADBEEF,
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x3 << 2)))
|
||||
Expect(b.Bytes()[2:6]).To(Equal([]byte{0xEF, 0xBE, 0xAD, 0xDE}))
|
||||
})
|
||||
|
@ -162,7 +162,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
StreamID: 1,
|
||||
Data: []byte("foobar"),
|
||||
Offset: 0x13DEADBEEF,
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x4 << 2)))
|
||||
Expect(b.Bytes()[2:7]).To(Equal([]byte{0xEF, 0xBE, 0xAD, 0xDE, 0x13}))
|
||||
})
|
||||
|
@ -173,7 +173,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
StreamID: 1,
|
||||
Data: []byte("foobar"),
|
||||
Offset: 0xDEADBEEFCAFE,
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x5 << 2)))
|
||||
Expect(b.Bytes()[2:8]).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE}))
|
||||
})
|
||||
|
@ -184,7 +184,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
StreamID: 1,
|
||||
Data: []byte("foobar"),
|
||||
Offset: 0x13DEADBEEFCAFE,
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x6 << 2)))
|
||||
Expect(b.Bytes()[2:9]).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE, 0x13}))
|
||||
})
|
||||
|
@ -195,7 +195,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
StreamID: 1,
|
||||
Data: []byte("foobar"),
|
||||
Offset: 0x1337DEADBEEFCAFE,
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x7 << 2)))
|
||||
Expect(b.Bytes()[2:10]).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE, 0x37, 0x13}))
|
||||
})
|
||||
|
@ -208,7 +208,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
StreamID: 1,
|
||||
streamIDLen: 13,
|
||||
Data: []byte("foobar"),
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(Equal(errInvalidStreamIDLen))
|
||||
})
|
||||
|
@ -218,7 +218,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
(&StreamFrame{
|
||||
StreamID: 13,
|
||||
Data: []byte("foobar"),
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x0)))
|
||||
Expect(b.Bytes()[1]).To(Equal(uint8(13)))
|
||||
})
|
||||
|
@ -228,7 +228,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
(&StreamFrame{
|
||||
StreamID: 0xCAFE,
|
||||
Data: []byte("foobar"),
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x1)))
|
||||
Expect(b.Bytes()[1:3]).To(Equal([]byte{0xFE, 0xCA}))
|
||||
})
|
||||
|
@ -238,7 +238,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
(&StreamFrame{
|
||||
StreamID: 0x13BEEF,
|
||||
Data: []byte("foobar"),
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x2)))
|
||||
Expect(b.Bytes()[1:4]).To(Equal([]byte{0xEF, 0xBE, 0x13}))
|
||||
})
|
||||
|
@ -248,7 +248,7 @@ var _ = Describe("StreamFrame", func() {
|
|||
(&StreamFrame{
|
||||
StreamID: 0xDECAFBAD,
|
||||
Data: []byte("foobar"),
|
||||
}).Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
}).Write(b, 1, 0)
|
||||
Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x3)))
|
||||
Expect(b.Bytes()[1:5]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE}))
|
||||
})
|
||||
|
|
|
@ -14,7 +14,7 @@ type WindowUpdateFrame struct {
|
|||
}
|
||||
|
||||
//Write writes a RST_STREAM frame
|
||||
func (f *WindowUpdateFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error {
|
||||
func (f *WindowUpdateFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, version protocol.VersionNumber) error {
|
||||
panic("WindowUpdateFrame: Write not yet implemented")
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ func (p *packetPacker) getPayload(frames []frames.Frame, currentPacketNumber pro
|
|||
var payload bytes.Buffer
|
||||
payload.WriteByte(0) // The entropy bit is set in sendPayload
|
||||
for _, frame := range frames {
|
||||
frame.Write(&payload, currentPacketNumber, 6, p.version)
|
||||
frame.Write(&payload, currentPacketNumber, p.version)
|
||||
}
|
||||
return payload.Bytes(), nil
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(p).ToNot(BeNil())
|
||||
b := &bytes.Buffer{}
|
||||
f.Write(b, 1, protocol.PacketNumberLen6, 0)
|
||||
f.Write(b, 1, 0)
|
||||
Expect(len(p.frames)).To(Equal(1))
|
||||
Expect(p.raw).To(ContainSubstring(string(b.Bytes())))
|
||||
})
|
||||
|
@ -118,7 +118,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("packs many control frames into 1 packets", func() {
|
||||
f := &frames.AckFrame{LargestObserved: 1}
|
||||
b := &bytes.Buffer{}
|
||||
f.Write(b, 3, protocol.PacketNumberLen6, 32)
|
||||
f.Write(b, 3, 32)
|
||||
maxFramesPerPacket := int(protocol.MaxFrameAndPublicHeaderSize-publicHeaderLen) / b.Len()
|
||||
var controlFrames []frames.Frame
|
||||
for i := 0; i < maxFramesPerPacket; i++ {
|
||||
|
@ -213,9 +213,9 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(p).ToNot(BeNil())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := &bytes.Buffer{}
|
||||
f1.Write(b, 2, protocol.PacketNumberLen6, 0)
|
||||
f2.Write(b, 2, protocol.PacketNumberLen6, 0)
|
||||
f3.Write(b, 2, protocol.PacketNumberLen6, 0)
|
||||
f1.Write(b, 2, 0)
|
||||
f2.Write(b, 2, 0)
|
||||
f3.Write(b, 2, 0)
|
||||
Expect(len(p.frames)).To(Equal(3))
|
||||
Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeTrue())
|
||||
Expect(p.frames[1].(*frames.StreamFrame).DataLenPresent).To(BeTrue())
|
||||
|
|
|
@ -50,7 +50,7 @@ var _ = Describe("Packet unpacker", func() {
|
|||
StreamID: 1,
|
||||
Data: []byte("foobar"),
|
||||
}
|
||||
err := f.Write(buf, 3, 6, 0)
|
||||
err := f.Write(buf, 3, 0)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
setReader(buf.Bytes())
|
||||
packet, err := unpacker.Unpack(hdrBin, hdr, r)
|
||||
|
@ -63,7 +63,7 @@ var _ = Describe("Packet unpacker", func() {
|
|||
LargestObserved: 1,
|
||||
DelayTime: time.Microsecond,
|
||||
}
|
||||
err := f.Write(buf, 3, 6, 32)
|
||||
err := f.Write(buf, 3, 32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
setReader(buf.Bytes())
|
||||
packet, err := unpacker.Unpack(hdrBin, hdr, r)
|
||||
|
@ -99,7 +99,7 @@ var _ = Describe("Packet unpacker", func() {
|
|||
|
||||
It("unpacks CONNECTION_CLOSE frames", func() {
|
||||
f := &frames.ConnectionCloseFrame{ReasonPhrase: "foo"}
|
||||
err := f.Write(buf, 6, 6, 0)
|
||||
err := f.Write(buf, 6, 0)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
setReader(buf.Bytes())
|
||||
packet, err := unpacker.Unpack(hdrBin, hdr, r)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue