diff --git a/frames/ack_frame.go b/frames/ack_frame.go index 192f1d38..c2858a88 100644 --- a/frames/ack_frame.go +++ b/frames/ack_frame.go @@ -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() { diff --git a/frames/ack_frame_test.go b/frames/ack_frame_test.go index 5d023651..6891b08b 100644 --- a/frames/ack_frame_test.go +++ b/frames/ack_frame_test.go @@ -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) diff --git a/frames/blocked_frame.go b/frames/blocked_frame.go index f3769683..a96a917a 100644 --- a/frames/blocked_frame.go +++ b/frames/blocked_frame.go @@ -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 { diff --git a/frames/blocked_frame_test.go b/frames/blocked_frame_test.go index c0ea23c3..4299fb9e 100644 --- a/frames/blocked_frame_test.go +++ b/frames/blocked_frame_test.go @@ -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})) }) diff --git a/frames/connection_close_frame.go b/frames/connection_close_frame.go index b65d6d6d..1a096746 100644 --- a/frames/connection_close_frame.go +++ b/frames/connection_close_frame.go @@ -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)) diff --git a/frames/connection_close_frame_test.go b/frames/connection_close_frame_test.go index dd326789..91a00755 100644 --- a/frames/connection_close_frame_test.go +++ b/frames/connection_close_frame_test.go @@ -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()) diff --git a/frames/frame.go b/frames/frame.go index 7bf2c0e3..ebbdc12d 100644 --- a/frames/frame.go +++ b/frames/frame.go @@ -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 } diff --git a/frames/ping_frame.go b/frames/ping_frame.go index ed69be85..7e66b7b3 100644 --- a/frames/ping_frame.go +++ b/frames/ping_frame.go @@ -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 diff --git a/frames/ping_frame_test.go b/frames/ping_frame_test.go index dae243c8..28581628 100644 --- a/frames/ping_frame_test.go +++ b/frames/ping_frame_test.go @@ -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})) }) diff --git a/frames/rst_stream_frame.go b/frames/rst_stream_frame.go index 4b6d35e0..c43d07b9 100644 --- a/frames/rst_stream_frame.go +++ b/frames/rst_stream_frame.go @@ -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") } diff --git a/frames/stop_waiting_frame.go b/frames/stop_waiting_frame.go index 01c4e786..a6a428c7 100644 --- a/frames/stop_waiting_frame.go +++ b/frames/stop_waiting_frame.go @@ -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) diff --git a/frames/stop_waiting_frame_test.go b/frames/stop_waiting_frame_test.go index 0adffd79..0d1814e3 100644 --- a/frames/stop_waiting_frame_test.go +++ b/frames/stop_waiting_frame_test.go @@ -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)) diff --git a/frames/stream_frame.go b/frames/stream_frame.go index 1e769fcf..05f0a20b 100644 --- a/frames/stream_frame.go +++ b/frames/stream_frame.go @@ -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 { diff --git a/frames/stream_frame_test.go b/frames/stream_frame_test.go index 769bf401..a7bd5d7b 100644 --- a/frames/stream_frame_test.go +++ b/frames/stream_frame_test.go @@ -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})) }) diff --git a/frames/window_update_frame.go b/frames/window_update_frame.go index 18df65e8..d28b8aab 100644 --- a/frames/window_update_frame.go +++ b/frames/window_update_frame.go @@ -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") } diff --git a/packet_packer.go b/packet_packer.go index 4428caf4..f4e01b60 100644 --- a/packet_packer.go +++ b/packet_packer.go @@ -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 } diff --git a/packet_packer_test.go b/packet_packer_test.go index 32a6b171..d09a39a7 100644 --- a/packet_packer_test.go +++ b/packet_packer_test.go @@ -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()) diff --git a/packet_unpacker_test.go b/packet_unpacker_test.go index 8543dd62..30a2c589 100644 --- a/packet_unpacker_test.go +++ b/packet_unpacker_test.go @@ -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)