diff --git a/fuzzing/frames/main.go b/fuzzing/frames/main.go index cf77d0df..25c81247 100644 --- a/fuzzing/frames/main.go +++ b/fuzzing/frames/main.go @@ -119,14 +119,14 @@ func getFrames() []wire.Frame { }, &wire.PingFrame{}, &wire.ResetStreamFrame{ - StreamID: protocol.StreamID(getRandomNumber()), - ErrorCode: quic.ErrorCode(getRandomNumber()), - ByteOffset: protocol.ByteCount(getRandomNumber()), + StreamID: protocol.StreamID(getRandomNumber()), + ErrorCode: quic.ErrorCode(getRandomNumber()), + FinalSize: protocol.ByteCount(getRandomNumber()), }, &wire.ResetStreamFrame{ // at maximum offset - StreamID: protocol.StreamID(getRandomNumber()), - ErrorCode: quic.ErrorCode(getRandomNumber()), - ByteOffset: protocol.MaxByteCount, + StreamID: protocol.StreamID(getRandomNumber()), + ErrorCode: quic.ErrorCode(getRandomNumber()), + FinalSize: protocol.MaxByteCount, }, &wire.StopSendingFrame{ StreamID: protocol.StreamID(getRandomNumber()), diff --git a/internal/wire/frame_parser_test.go b/internal/wire/frame_parser_test.go index 76239a12..8ceccf1d 100644 --- a/internal/wire/frame_parser_test.go +++ b/internal/wire/frame_parser_test.go @@ -82,9 +82,9 @@ var _ = Describe("Frame parsing", func() { It("unpacks RESET_STREAM frames", func() { f := &ResetStreamFrame{ - StreamID: 0xdeadbeef, - ByteOffset: 0xdecafbad1234, - ErrorCode: 0x1337, + StreamID: 0xdeadbeef, + FinalSize: 0xdecafbad1234, + ErrorCode: 0x1337, } err := f.Write(buf, versionIETFFrames) Expect(err).ToNot(HaveOccurred()) diff --git a/internal/wire/log.go b/internal/wire/log.go index 9549bd0e..88279842 100644 --- a/internal/wire/log.go +++ b/internal/wire/log.go @@ -24,7 +24,7 @@ func LogFrame(logger utils.Logger, frame Frame, sent bool) { case *StreamFrame: logger.Debugf("\t%s &wire.StreamFrame{StreamID: %d, FinBit: %t, Offset: %d, Data length: %d, Offset + Data length: %d}", dir, f.StreamID, f.FinBit, f.Offset, f.DataLen(), f.Offset+f.DataLen()) case *ResetStreamFrame: - logger.Debugf("\t%s &wire.ResetStreamFrame{StreamID: %d, ErrorCode: %#x, ByteOffset: %d}", dir, f.StreamID, f.ErrorCode, f.ByteOffset) + logger.Debugf("\t%s &wire.ResetStreamFrame{StreamID: %d, ErrorCode: %#x, FinalSize: %d}", dir, f.StreamID, f.ErrorCode, f.FinalSize) case *AckFrame: if len(f.AckRanges) > 1 { ackRanges := make([]string, len(f.AckRanges)) diff --git a/internal/wire/log_test.go b/internal/wire/log_test.go index cddf26e3..4ebf0bb2 100644 --- a/internal/wire/log_test.go +++ b/internal/wire/log_test.go @@ -38,12 +38,12 @@ var _ = Describe("Frame logging", func() { It("logs sent frames", func() { LogFrame(logger, &ResetStreamFrame{}, true) - Expect(buf.String()).To(ContainSubstring("\t-> &wire.ResetStreamFrame{StreamID: 0, ErrorCode: 0x0, ByteOffset: 0}\n")) + Expect(buf.String()).To(ContainSubstring("\t-> &wire.ResetStreamFrame{StreamID: 0, ErrorCode: 0x0, FinalSize: 0}\n")) }) It("logs received frames", func() { LogFrame(logger, &ResetStreamFrame{}, false) - Expect(buf.String()).To(ContainSubstring("\t<- &wire.ResetStreamFrame{StreamID: 0, ErrorCode: 0x0, ByteOffset: 0}\n")) + Expect(buf.String()).To(ContainSubstring("\t<- &wire.ResetStreamFrame{StreamID: 0, ErrorCode: 0x0, FinalSize: 0}\n")) }) It("logs CRYPTO frames", func() { diff --git a/internal/wire/reset_stream_frame.go b/internal/wire/reset_stream_frame.go index b93a705e..807bd49b 100644 --- a/internal/wire/reset_stream_frame.go +++ b/internal/wire/reset_stream_frame.go @@ -9,9 +9,9 @@ import ( // A ResetStreamFrame is a RESET_STREAM frame in QUIC type ResetStreamFrame struct { - StreamID protocol.StreamID - ErrorCode protocol.ApplicationErrorCode - ByteOffset protocol.ByteCount + StreamID protocol.StreamID + ErrorCode protocol.ApplicationErrorCode + FinalSize protocol.ByteCount } func parseResetStreamFrame(r *bytes.Reader, _ protocol.VersionNumber) (*ResetStreamFrame, error) { @@ -37,9 +37,9 @@ func parseResetStreamFrame(r *bytes.Reader, _ protocol.VersionNumber) (*ResetStr byteOffset = protocol.ByteCount(bo) return &ResetStreamFrame{ - StreamID: streamID, - ErrorCode: protocol.ApplicationErrorCode(errorCode), - ByteOffset: byteOffset, + StreamID: streamID, + ErrorCode: protocol.ApplicationErrorCode(errorCode), + FinalSize: byteOffset, }, nil } @@ -47,11 +47,11 @@ func (f *ResetStreamFrame) Write(b *bytes.Buffer, _ protocol.VersionNumber) erro b.WriteByte(0x4) utils.WriteVarInt(b, uint64(f.StreamID)) utils.WriteVarInt(b, uint64(f.ErrorCode)) - utils.WriteVarInt(b, uint64(f.ByteOffset)) + utils.WriteVarInt(b, uint64(f.FinalSize)) return nil } // Length of a written frame func (f *ResetStreamFrame) Length(version protocol.VersionNumber) protocol.ByteCount { - return 1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.ErrorCode)) + utils.VarIntLen(uint64(f.ByteOffset)) + return 1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.ErrorCode)) + utils.VarIntLen(uint64(f.FinalSize)) } diff --git a/internal/wire/reset_stream_frame_test.go b/internal/wire/reset_stream_frame_test.go index 3580e491..eb4b66b4 100644 --- a/internal/wire/reset_stream_frame_test.go +++ b/internal/wire/reset_stream_frame_test.go @@ -20,7 +20,7 @@ var _ = Describe("RESET_STREAM frame", func() { frame, err := parseResetStreamFrame(b, versionIETFFrames) Expect(err).ToNot(HaveOccurred()) Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef))) - Expect(frame.ByteOffset).To(Equal(protocol.ByteCount(0x987654321))) + Expect(frame.FinalSize).To(Equal(protocol.ByteCount(0x987654321))) Expect(frame.ErrorCode).To(Equal(protocol.ApplicationErrorCode(0x1337))) }) @@ -41,9 +41,9 @@ var _ = Describe("RESET_STREAM frame", func() { Context("when writing", func() { It("writes a sample frame", func() { frame := ResetStreamFrame{ - StreamID: 0x1337, - ByteOffset: 0x11223344decafbad, - ErrorCode: 0xcafe, + StreamID: 0x1337, + FinalSize: 0x11223344decafbad, + ErrorCode: 0xcafe, } b := &bytes.Buffer{} err := frame.Write(b, versionIETFFrames) @@ -57,9 +57,9 @@ var _ = Describe("RESET_STREAM frame", func() { It("has the correct min length", func() { rst := ResetStreamFrame{ - StreamID: 0x1337, - ByteOffset: 0x1234567, - ErrorCode: 0xde, + StreamID: 0x1337, + FinalSize: 0x1234567, + ErrorCode: 0xde, } expectedLen := 1 + utils.VarIntLen(0x1337) + utils.VarIntLen(0x1234567) + 2 Expect(rst.Length(versionIETFFrames)).To(Equal(expectedLen)) diff --git a/qlog/frame.go b/qlog/frame.go index 61fd139f..26853e75 100644 --- a/qlog/frame.go +++ b/qlog/frame.go @@ -142,7 +142,7 @@ func marshalResetStreamFrame(enc *gojay.Encoder, f *wire.ResetStreamFrame) { enc.StringKey("frame_type", "reset_stream") enc.Int64Key("stream_id", int64(f.StreamID)) enc.Int64Key("error_code", int64(f.ErrorCode)) - enc.Int64Key("final_size", int64(f.ByteOffset)) + enc.Int64Key("final_size", int64(f.FinalSize)) } func marshalStopSendingFrame(enc *gojay.Encoder, f *wire.StopSendingFrame) { diff --git a/qlog/frame_test.go b/qlog/frame_test.go index bf9d8adf..08d616dd 100644 --- a/qlog/frame_test.go +++ b/qlog/frame_test.go @@ -84,9 +84,9 @@ var _ = Describe("Frames", func() { It("marshals RESET_STREAM frames", func() { check( &wire.ResetStreamFrame{ - StreamID: 987, - ByteOffset: 1234, - ErrorCode: 42, + StreamID: 987, + FinalSize: 1234, + ErrorCode: 42, }, map[string]interface{}{ "frame_type": "reset_stream", diff --git a/receive_stream.go b/receive_stream.go index 33b6fdec..21157870 100644 --- a/receive_stream.go +++ b/receive_stream.go @@ -268,11 +268,11 @@ func (s *receiveStream) handleResetStreamFrameImpl(frame *wire.ResetStreamFrame) if s.closedForShutdown { return false, nil } - if err := s.flowController.UpdateHighestReceived(frame.ByteOffset, true); err != nil { + if err := s.flowController.UpdateHighestReceived(frame.FinalSize, true); err != nil { return false, err } newlyRcvdFinalOffset := s.finalOffset == protocol.MaxByteCount - s.finalOffset = frame.ByteOffset + s.finalOffset = frame.FinalSize // ignore duplicate RESET_STREAM frames for this stream (after checking their final offset) if s.resetRemotely { diff --git a/receive_stream_test.go b/receive_stream_test.go index 479b600f..d293cc0c 100644 --- a/receive_stream_test.go +++ b/receive_stream_test.go @@ -507,8 +507,8 @@ var _ = Describe("Receive Stream", func() { ) mockSender.EXPECT().onStreamCompleted(streamID) Expect(str.handleResetStreamFrame(&wire.ResetStreamFrame{ - StreamID: streamID, - ByteOffset: 42, + StreamID: streamID, + FinalSize: 42, })).To(Succeed()) str.CancelRead(1234) }) @@ -561,9 +561,9 @@ var _ = Describe("Receive Stream", func() { Context("receiving RESET_STREAM frames", func() { rst := &wire.ResetStreamFrame{ - StreamID: streamID, - ByteOffset: 42, - ErrorCode: 1234, + StreamID: streamID, + FinalSize: 42, + ErrorCode: 1234, } It("unblocks Read", func() { @@ -624,7 +624,7 @@ var _ = Describe("Receive Stream", func() { mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true).Times(2) Expect(str.handleStreamFrame(&wire.StreamFrame{ StreamID: streamID, - Offset: rst.ByteOffset, + Offset: rst.FinalSize, FinBit: true, })).To(Succeed()) Expect(str.handleResetStreamFrame(rst)).To(Succeed()) diff --git a/send_stream.go b/send_stream.go index d34cb8c6..431e6b5d 100644 --- a/send_stream.go +++ b/send_stream.go @@ -416,9 +416,9 @@ func (s *sendStream) cancelWriteImpl(errorCode protocol.ApplicationErrorCode, wr s.signalWrite() s.sender.queueControlFrame(&wire.ResetStreamFrame{ - StreamID: s.streamID, - ByteOffset: s.writeOffset, - ErrorCode: errorCode, + StreamID: s.streamID, + FinalSize: s.writeOffset, + ErrorCode: errorCode, }) if newlyCompleted { s.sender.onStreamCompleted(s.streamID) diff --git a/send_stream_test.go b/send_stream_test.go index 41eca8f5..cb692c04 100644 --- a/send_stream_test.go +++ b/send_stream_test.go @@ -685,9 +685,9 @@ var _ = Describe("Send Stream", func() { It("queues a RESET_STREAM frame", func() { gomock.InOrder( mockSender.EXPECT().queueControlFrame(&wire.ResetStreamFrame{ - StreamID: streamID, - ByteOffset: 1234, - ErrorCode: 9876, + StreamID: streamID, + FinalSize: 1234, + ErrorCode: 9876, }), mockSender.EXPECT().onStreamCompleted(streamID), ) diff --git a/session_test.go b/session_test.go index 519af3cf..f28ad68d 100644 --- a/session_test.go +++ b/session_test.go @@ -169,9 +169,9 @@ var _ = Describe("Session", func() { Context("handling RESET_STREAM frames", func() { It("closes the streams for writing", func() { f := &wire.ResetStreamFrame{ - StreamID: 555, - ErrorCode: 42, - ByteOffset: 0x1337, + StreamID: 555, + ErrorCode: 42, + FinalSize: 0x1337, } str := NewMockReceiveStreamI(mockCtrl) streamManager.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(555)).Return(str, nil) @@ -182,8 +182,8 @@ var _ = Describe("Session", func() { It("returns errors", func() { f := &wire.ResetStreamFrame{ - StreamID: 7, - ByteOffset: 0x1337, + StreamID: 7, + FinalSize: 0x1337, } testErr := errors.New("flow control violation") str := NewMockReceiveStreamI(mockCtrl)