diff --git a/fuzzing/frames/main.go b/fuzzing/frames/main.go index 86c4f2af..1432e4ee 100644 --- a/fuzzing/frames/main.go +++ b/fuzzing/frames/main.go @@ -149,12 +149,12 @@ func getFrames() []wire.Frame { MaximumData: protocol.MaxByteCount, }, &wire.MaxStreamDataFrame{ - StreamID: protocol.StreamID(getRandomNumber()), - ByteOffset: protocol.ByteCount(getRandomNumber()), + StreamID: protocol.StreamID(getRandomNumber()), + MaximumStreamData: protocol.ByteCount(getRandomNumber()), }, &wire.MaxStreamDataFrame{ - StreamID: protocol.StreamID(getRandomNumber()), - ByteOffset: protocol.MaxByteCount, + StreamID: protocol.StreamID(getRandomNumber()), + MaximumStreamData: protocol.MaxByteCount, }, &wire.MaxStreamsFrame{ Type: protocol.StreamTypeUni, diff --git a/internal/wire/frame_parser_test.go b/internal/wire/frame_parser_test.go index d3f1a1b9..37d68547 100644 --- a/internal/wire/frame_parser_test.go +++ b/internal/wire/frame_parser_test.go @@ -155,8 +155,8 @@ var _ = Describe("Frame parsing", func() { It("unpacks MAX_STREAM_DATA frames", func() { f := &MaxStreamDataFrame{ - StreamID: 0xdeadbeef, - ByteOffset: 0xdecafbad, + StreamID: 0xdeadbeef, + MaximumStreamData: 0xdecafbad, } buf := &bytes.Buffer{} err := f.Write(buf, versionIETFFrames) @@ -287,8 +287,8 @@ var _ = Describe("Frame parsing", func() { It("errors on invalid frames", func() { f := &MaxStreamDataFrame{ - StreamID: 0x1337, - ByteOffset: 0xdeadbeef, + StreamID: 0x1337, + MaximumStreamData: 0xdeadbeef, } b := &bytes.Buffer{} f.Write(b, versionIETFFrames) diff --git a/internal/wire/log.go b/internal/wire/log.go index 56ea84ed..e72aa566 100644 --- a/internal/wire/log.go +++ b/internal/wire/log.go @@ -38,7 +38,7 @@ func LogFrame(logger utils.Logger, frame Frame, sent bool) { case *MaxDataFrame: logger.Debugf("\t%s &wire.MaxDataFrame{MaximumData: %d}", dir, f.MaximumData) case *MaxStreamDataFrame: - logger.Debugf("\t%s &wire.MaxStreamDataFrame{StreamID: %d, ByteOffset: %d}", dir, f.StreamID, f.ByteOffset) + logger.Debugf("\t%s &wire.MaxStreamDataFrame{StreamID: %d, MaximumStreamData: %d}", dir, f.StreamID, f.MaximumStreamData) case *DataBlockedFrame: logger.Debugf("\t%s &wire.DataBlockedFrame{DataLimit: %d}", dir, f.DataLimit) case *StreamDataBlockedFrame: diff --git a/internal/wire/log_test.go b/internal/wire/log_test.go index e43b1d00..0d2a7ebf 100644 --- a/internal/wire/log_test.go +++ b/internal/wire/log_test.go @@ -106,11 +106,11 @@ var _ = Describe("Frame logging", func() { It("logs MAX_STREAM_DATA frames", func() { frame := &MaxStreamDataFrame{ - StreamID: 10, - ByteOffset: 42, + StreamID: 10, + MaximumStreamData: 42, } LogFrame(logger, frame, false) - Expect(buf.String()).To(ContainSubstring("\t<- &wire.MaxStreamDataFrame{StreamID: 10, ByteOffset: 42}\n")) + Expect(buf.String()).To(ContainSubstring("\t<- &wire.MaxStreamDataFrame{StreamID: 10, MaximumStreamData: 42}\n")) }) It("logs DATA_BLOCKED frames", func() { diff --git a/internal/wire/max_stream_data_frame.go b/internal/wire/max_stream_data_frame.go index e5f4a2cd..2fea8656 100644 --- a/internal/wire/max_stream_data_frame.go +++ b/internal/wire/max_stream_data_frame.go @@ -9,8 +9,8 @@ import ( // A MaxStreamDataFrame is a MAX_STREAM_DATA frame type MaxStreamDataFrame struct { - StreamID protocol.StreamID - ByteOffset protocol.ByteCount + StreamID protocol.StreamID + MaximumStreamData protocol.ByteCount } func parseMaxStreamDataFrame(r *bytes.Reader, _ protocol.VersionNumber) (*MaxStreamDataFrame, error) { @@ -28,19 +28,19 @@ func parseMaxStreamDataFrame(r *bytes.Reader, _ protocol.VersionNumber) (*MaxStr } return &MaxStreamDataFrame{ - StreamID: protocol.StreamID(sid), - ByteOffset: protocol.ByteCount(offset), + StreamID: protocol.StreamID(sid), + MaximumStreamData: protocol.ByteCount(offset), }, nil } func (f *MaxStreamDataFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { b.WriteByte(0x11) utils.WriteVarInt(b, uint64(f.StreamID)) - utils.WriteVarInt(b, uint64(f.ByteOffset)) + utils.WriteVarInt(b, uint64(f.MaximumStreamData)) return nil } // Length of a written frame func (f *MaxStreamDataFrame) Length(version protocol.VersionNumber) protocol.ByteCount { - return 1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.ByteOffset)) + return 1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.MaximumStreamData)) } diff --git a/internal/wire/max_stream_data_frame_test.go b/internal/wire/max_stream_data_frame_test.go index 3c164850..663bbf36 100644 --- a/internal/wire/max_stream_data_frame_test.go +++ b/internal/wire/max_stream_data_frame_test.go @@ -19,7 +19,7 @@ var _ = Describe("MAX_STREAM_DATA frame", func() { frame, err := parseMaxStreamDataFrame(b, versionIETFFrames) Expect(err).ToNot(HaveOccurred()) Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef))) - Expect(frame.ByteOffset).To(Equal(protocol.ByteCount(0x12345678))) + Expect(frame.MaximumStreamData).To(Equal(protocol.ByteCount(0x12345678))) Expect(b.Len()).To(BeZero()) }) @@ -39,17 +39,17 @@ var _ = Describe("MAX_STREAM_DATA frame", func() { Context("writing", func() { It("has proper min length", func() { f := &MaxStreamDataFrame{ - StreamID: 0x1337, - ByteOffset: 0xdeadbeef, + StreamID: 0x1337, + MaximumStreamData: 0xdeadbeef, } - Expect(f.Length(protocol.VersionWhatever)).To(Equal(1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.ByteOffset)))) + Expect(f.Length(protocol.VersionWhatever)).To(Equal(1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.MaximumStreamData)))) }) It("writes a sample frame", func() { b := &bytes.Buffer{} f := &MaxStreamDataFrame{ - StreamID: 0xdecafbad, - ByteOffset: 0xdeadbeefcafe42, + StreamID: 0xdecafbad, + MaximumStreamData: 0xdeadbeefcafe42, } expected := []byte{0x11} expected = append(expected, encodeVarInt(0xdecafbad)...) diff --git a/qlog/frame.go b/qlog/frame.go index b296d0bb..daee30c9 100644 --- a/qlog/frame.go +++ b/qlog/frame.go @@ -179,7 +179,7 @@ func marshalMaxDataFrame(enc *gojay.Encoder, f *wire.MaxDataFrame) { func marshalMaxStreamDataFrame(enc *gojay.Encoder, f *wire.MaxStreamDataFrame) { enc.StringKey("frame_type", "max_stream_data") enc.Int64Key("stream_id", int64(f.StreamID)) - enc.Int64Key("maximum", int64(f.ByteOffset)) + enc.Int64Key("maximum", int64(f.MaximumStreamData)) } func marshalMaxStreamsFrame(enc *gojay.Encoder, f *wire.MaxStreamsFrame) { diff --git a/qlog/frame_test.go b/qlog/frame_test.go index 801d86e6..c5c1787f 100644 --- a/qlog/frame_test.go +++ b/qlog/frame_test.go @@ -187,8 +187,8 @@ var _ = Describe("Frames", func() { It("marshals MAX_STREAM_DATA frames", func() { check( &wire.MaxStreamDataFrame{ - StreamID: 1234, - ByteOffset: 1337, + StreamID: 1234, + MaximumStreamData: 1337, }, map[string]interface{}{ "frame_type": "max_stream_data", diff --git a/qlog/qlog_test.go b/qlog/qlog_test.go index 2931b7dd..01dab12c 100644 --- a/qlog/qlog_test.go +++ b/qlog/qlog_test.go @@ -270,7 +270,7 @@ var _ = Describe("Tracer", func() { 987, nil, []wire.Frame{ - &wire.MaxStreamDataFrame{StreamID: 42, ByteOffset: 987}, + &wire.MaxStreamDataFrame{StreamID: 42, MaximumStreamData: 987}, &wire.StreamFrame{StreamID: 123, Offset: 1234, Data: []byte("foobar"), FinBit: true}, }, ) @@ -327,7 +327,7 @@ var _ = Describe("Tracer", func() { }, 789, []wire.Frame{ - &wire.MaxStreamDataFrame{StreamID: 42, ByteOffset: 987}, + &wire.MaxStreamDataFrame{StreamID: 42, MaximumStreamData: 987}, &wire.StreamFrame{StreamID: 123, Offset: 1234, Data: []byte("foobar"), FinBit: true}, }, ) diff --git a/send_stream.go b/send_stream.go index a27c2253..6f57eaef 100644 --- a/send_stream.go +++ b/send_stream.go @@ -430,7 +430,7 @@ func (s *sendStream) handleMaxStreamDataFrame(frame *wire.MaxStreamDataFrame) { hasStreamData := s.dataForWriting != nil || s.nextFrame != nil s.mutex.Unlock() - s.flowController.UpdateSendWindow(frame.ByteOffset) + s.flowController.UpdateSendWindow(frame.MaximumStreamData) if hasStreamData { s.sender.onHasStreamData(s.streamID) } diff --git a/send_stream_test.go b/send_stream_test.go index 0dd65fdf..5192ec06 100644 --- a/send_stream_test.go +++ b/send_stream_test.go @@ -653,8 +653,8 @@ var _ = Describe("Send Stream", func() { It("informs the flow controller", func() { mockFC.EXPECT().UpdateSendWindow(protocol.ByteCount(0x1337)) str.handleMaxStreamDataFrame(&wire.MaxStreamDataFrame{ - StreamID: streamID, - ByteOffset: 0x1337, + StreamID: streamID, + MaximumStreamData: 0x1337, }) }) @@ -671,8 +671,8 @@ var _ = Describe("Send Stream", func() { waitForWrite() mockSender.EXPECT().onHasStreamData(streamID) str.handleMaxStreamDataFrame(&wire.MaxStreamDataFrame{ - StreamID: streamID, - ByteOffset: 42, + StreamID: streamID, + MaximumStreamData: 42, }) // make sure the Write go routine returns str.closeForShutdown(nil) diff --git a/session_test.go b/session_test.go index e5ceafd6..90b5df65 100644 --- a/session_test.go +++ b/session_test.go @@ -212,8 +212,8 @@ var _ = Describe("Session", func() { It("updates the flow control window of a stream", func() { f := &wire.MaxStreamDataFrame{ - StreamID: 12345, - ByteOffset: 0x1337, + StreamID: 12345, + MaximumStreamData: 0x1337, } str := NewMockSendStreamI(mockCtrl) streamManager.EXPECT().GetOrOpenSendStream(protocol.StreamID(12345)).Return(str, nil) @@ -231,8 +231,8 @@ var _ = Describe("Session", func() { It("ignores MAX_STREAM_DATA frames for a closed stream", func() { streamManager.EXPECT().GetOrOpenSendStream(protocol.StreamID(10)).Return(nil, nil) Expect(sess.handleFrame(&wire.MaxStreamDataFrame{ - StreamID: 10, - ByteOffset: 1337, + StreamID: 10, + MaximumStreamData: 1337, }, protocol.EncryptionUnspecified)).To(Succeed()) }) }) diff --git a/window_update_queue.go b/window_update_queue.go index f3188dbe..2abcf673 100644 --- a/window_update_queue.go +++ b/window_update_queue.go @@ -63,8 +63,8 @@ func (q *windowUpdateQueue) QueueAll() { continue } q.callback(&wire.MaxStreamDataFrame{ - StreamID: id, - ByteOffset: offset, + StreamID: id, + MaximumStreamData: offset, }) } q.mutex.Unlock() diff --git a/window_update_queue_test.go b/window_update_queue_test.go index 45869f03..4ad52d47 100644 --- a/window_update_queue_test.go +++ b/window_update_queue_test.go @@ -36,8 +36,8 @@ var _ = Describe("Window Update Queue", func() { q.AddStream(3) q.AddStream(1) q.QueueAll() - Expect(queuedFrames).To(ContainElement(&wire.MaxStreamDataFrame{StreamID: 1, ByteOffset: 10})) - Expect(queuedFrames).To(ContainElement(&wire.MaxStreamDataFrame{StreamID: 3, ByteOffset: 30})) + Expect(queuedFrames).To(ContainElement(&wire.MaxStreamDataFrame{StreamID: 1, MaximumStreamData: 10})) + Expect(queuedFrames).To(ContainElement(&wire.MaxStreamDataFrame{StreamID: 3, MaximumStreamData: 30})) }) It("deletes the entry after getting the MAX_STREAM_DATA frame", func() { @@ -106,7 +106,7 @@ var _ = Describe("Window Update Queue", func() { q.AddStream(10) q.QueueAll() Expect(queuedFrames).To(Equal([]wire.Frame{ - &wire.MaxStreamDataFrame{StreamID: 10, ByteOffset: 200}, + &wire.MaxStreamDataFrame{StreamID: 10, MaximumStreamData: 200}, })) }) })