diff --git a/framer_test.go b/framer_test.go index 04caf767..817f2b5e 100644 --- a/framer_test.go +++ b/framer_test.go @@ -38,7 +38,7 @@ var _ = Describe("Framer", func() { Context("handling control frames", func() { It("adds control frames", func() { - mdf := &wire.MaxDataFrame{ByteOffset: 0x42} + mdf := &wire.MaxDataFrame{MaximumData: 0x42} msf := &wire.MaxStreamsFrame{MaxStreamNum: 0x1337} framer.QueueControlFrame(mdf) framer.QueueControlFrame(msf) @@ -52,7 +52,7 @@ var _ = Describe("Framer", func() { It("says if it has data", func() { Expect(framer.HasData()).To(BeFalse()) - f := &wire.MaxDataFrame{ByteOffset: 0x42} + f := &wire.MaxDataFrame{MaximumData: 0x42} framer.QueueControlFrame(f) Expect(framer.HasData()).To(BeTrue()) frames, _ := framer.AppendControlFrames(nil, 1000) @@ -62,7 +62,7 @@ var _ = Describe("Framer", func() { It("appends to the slice given", func() { ping := &wire.PingFrame{} - mdf := &wire.MaxDataFrame{ByteOffset: 0x42} + mdf := &wire.MaxDataFrame{MaximumData: 0x42} framer.QueueControlFrame(mdf) frames, length := framer.AppendControlFrames([]ackhandler.Frame{{Frame: ping}}, 1000) Expect(frames).To(HaveLen(2)) @@ -137,7 +137,7 @@ var _ = Describe("Framer", func() { } stream1.EXPECT().popStreamFrame(gomock.Any()).Return(&ackhandler.Frame{Frame: f}, false) framer.AddActiveStream(id1) - mdf := &wire.MaxDataFrame{ByteOffset: 1337} + mdf := &wire.MaxDataFrame{MaximumData: 1337} frames := []ackhandler.Frame{{Frame: mdf}} fs, length := framer.AppendStreamFrames(frames, 1000) Expect(fs).To(HaveLen(2)) diff --git a/fuzzing/frames/main.go b/fuzzing/frames/main.go index 4ba96c5d..86c4f2af 100644 --- a/fuzzing/frames/main.go +++ b/fuzzing/frames/main.go @@ -143,10 +143,10 @@ func getFrames() []wire.Frame { Token: getRandomData(10), }, &wire.MaxDataFrame{ - ByteOffset: protocol.ByteCount(getRandomNumber()), + MaximumData: protocol.ByteCount(getRandomNumber()), }, &wire.MaxDataFrame{ - ByteOffset: protocol.MaxByteCount, + MaximumData: protocol.MaxByteCount, }, &wire.MaxStreamDataFrame{ StreamID: protocol.StreamID(getRandomNumber()), diff --git a/internal/wire/frame_parser_test.go b/internal/wire/frame_parser_test.go index b24b9554..d3f1a1b9 100644 --- a/internal/wire/frame_parser_test.go +++ b/internal/wire/frame_parser_test.go @@ -143,7 +143,7 @@ var _ = Describe("Frame parsing", func() { It("unpacks MAX_DATA frames", func() { f := &MaxDataFrame{ - ByteOffset: 0xcafe, + MaximumData: 0xcafe, } buf := &bytes.Buffer{} err := f.Write(buf, versionIETFFrames) diff --git a/internal/wire/log.go b/internal/wire/log.go index 34617822..56ea84ed 100644 --- a/internal/wire/log.go +++ b/internal/wire/log.go @@ -36,7 +36,7 @@ func LogFrame(logger utils.Logger, frame Frame, sent bool) { logger.Debugf("\t%s &wire.AckFrame{LargestAcked: %d, LowestAcked: %d, DelayTime: %s}", dir, f.LargestAcked(), f.LowestAcked(), f.DelayTime.String()) } case *MaxDataFrame: - logger.Debugf("\t%s &wire.MaxDataFrame{ByteOffset: %d}", dir, f.ByteOffset) + 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) case *DataBlockedFrame: diff --git a/internal/wire/log_test.go b/internal/wire/log_test.go index c8e5f694..e43b1d00 100644 --- a/internal/wire/log_test.go +++ b/internal/wire/log_test.go @@ -98,10 +98,10 @@ var _ = Describe("Frame logging", func() { It("logs MAX_DATA frames", func() { frame := &MaxDataFrame{ - ByteOffset: 42, + MaximumData: 42, } LogFrame(logger, frame, false) - Expect(buf.String()).To(ContainSubstring("\t<- &wire.MaxDataFrame{ByteOffset: 42}\n")) + Expect(buf.String()).To(ContainSubstring("\t<- &wire.MaxDataFrame{MaximumData: 42}\n")) }) It("logs MAX_STREAM_DATA frames", func() { diff --git a/internal/wire/max_data_frame.go b/internal/wire/max_data_frame.go index 60051bd7..4fd9a1b1 100644 --- a/internal/wire/max_data_frame.go +++ b/internal/wire/max_data_frame.go @@ -9,7 +9,7 @@ import ( // A MaxDataFrame carries flow control information for the connection type MaxDataFrame struct { - ByteOffset protocol.ByteCount + MaximumData protocol.ByteCount } // parseMaxDataFrame parses a MAX_DATA frame @@ -23,18 +23,18 @@ func parseMaxDataFrame(r *bytes.Reader, _ protocol.VersionNumber) (*MaxDataFrame if err != nil { return nil, err } - frame.ByteOffset = protocol.ByteCount(byteOffset) + frame.MaximumData = protocol.ByteCount(byteOffset) return frame, nil } //Write writes a MAX_STREAM_DATA frame func (f *MaxDataFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { b.WriteByte(0x10) - utils.WriteVarInt(b, uint64(f.ByteOffset)) + utils.WriteVarInt(b, uint64(f.MaximumData)) return nil } // Length of a written frame func (f *MaxDataFrame) Length(version protocol.VersionNumber) protocol.ByteCount { - return 1 + utils.VarIntLen(uint64(f.ByteOffset)) + return 1 + utils.VarIntLen(uint64(f.MaximumData)) } diff --git a/internal/wire/max_data_frame_test.go b/internal/wire/max_data_frame_test.go index 86ead917..b1c74ba8 100644 --- a/internal/wire/max_data_frame_test.go +++ b/internal/wire/max_data_frame_test.go @@ -17,7 +17,7 @@ var _ = Describe("MAX_DATA frame", func() { b := bytes.NewReader(data) frame, err := parseMaxDataFrame(b, versionIETFFrames) Expect(err).ToNot(HaveOccurred()) - Expect(frame.ByteOffset).To(Equal(protocol.ByteCount(0xdecafbad123456))) + Expect(frame.MaximumData).To(Equal(protocol.ByteCount(0xdecafbad123456))) Expect(b.Len()).To(BeZero()) }) @@ -36,7 +36,7 @@ var _ = Describe("MAX_DATA frame", func() { Context("writing", func() { It("has proper min length", func() { f := &MaxDataFrame{ - ByteOffset: 0xdeadbeef, + MaximumData: 0xdeadbeef, } Expect(f.Length(versionIETFFrames)).To(Equal(1 + utils.VarIntLen(0xdeadbeef))) }) @@ -44,7 +44,7 @@ var _ = Describe("MAX_DATA frame", func() { It("writes a MAX_DATA frame", func() { b := &bytes.Buffer{} f := &MaxDataFrame{ - ByteOffset: 0xdeadbeefcafe, + MaximumData: 0xdeadbeefcafe, } err := f.Write(b, versionIETFFrames) Expect(err).ToNot(HaveOccurred()) diff --git a/packet_packer_test.go b/packet_packer_test.go index 685eee07..88aedc43 100644 --- a/packet_packer_test.go +++ b/packet_packer_test.go @@ -259,7 +259,7 @@ var _ = Describe("Packet packer", func() { sealingManager.EXPECT().Get0RTTSealer().Return(getSealer(), nil).AnyTimes() pnManager.EXPECT().PeekPacketNumber(protocol.Encryption0RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2) pnManager.EXPECT().PopPacketNumber(protocol.Encryption0RTT).Return(protocol.PacketNumber(0x42)) - cf := ackhandler.Frame{Frame: &wire.MaxDataFrame{ByteOffset: 0x1337}} + cf := ackhandler.Frame{Frame: &wire.MaxDataFrame{MaximumData: 0x1337}} framer.EXPECT().HasData().Return(true) framer.EXPECT().AppendControlFrames(nil, gomock.Any()).DoAndReturn(func(frames []ackhandler.Frame, _ protocol.ByteCount) ([]ackhandler.Frame, protocol.ByteCount) { return append(frames, cf), cf.Length(packer.version) diff --git a/qlog/frame.go b/qlog/frame.go index b820997b..b296d0bb 100644 --- a/qlog/frame.go +++ b/qlog/frame.go @@ -173,7 +173,7 @@ func marshalStreamFrame(enc *gojay.Encoder, f *streamFrame) { func marshalMaxDataFrame(enc *gojay.Encoder, f *wire.MaxDataFrame) { enc.StringKey("frame_type", "max_data") - enc.Int64Key("maximum", int64(f.ByteOffset)) + enc.Int64Key("maximum", int64(f.MaximumData)) } func marshalMaxStreamDataFrame(enc *gojay.Encoder, f *wire.MaxStreamDataFrame) { diff --git a/qlog/frame_test.go b/qlog/frame_test.go index a3bfd93b..801d86e6 100644 --- a/qlog/frame_test.go +++ b/qlog/frame_test.go @@ -175,7 +175,7 @@ var _ = Describe("Frames", func() { It("marshals MAX_DATA frames", func() { check( &wire.MaxDataFrame{ - ByteOffset: 1337, + MaximumData: 1337, }, map[string]interface{}{ "frame_type": "max_data", diff --git a/qlog/qlog_test.go b/qlog/qlog_test.go index e2bf7b23..2931b7dd 100644 --- a/qlog/qlog_test.go +++ b/qlog/qlog_test.go @@ -300,7 +300,7 @@ var _ = Describe("Tracer", func() { }, 123, &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}, - []wire.Frame{&wire.MaxDataFrame{ByteOffset: 987}}, + []wire.Frame{&wire.MaxDataFrame{MaximumData: 987}}, ) entry := exportAndParseSingle() ev := entry.Event diff --git a/retransmission_queue_test.go b/retransmission_queue_test.go index 213f732f..10415dab 100644 --- a/retransmission_queue_test.go +++ b/retransmission_queue_test.go @@ -24,7 +24,7 @@ var _ = Describe("Retransmission queue", func() { }) It("queues and retrieves a control frame", func() { - f := &wire.MaxDataFrame{ByteOffset: 0x42} + f := &wire.MaxDataFrame{MaximumData: 0x42} q.AddInitial(f) Expect(q.HasInitialData()).To(BeTrue()) Expect(q.GetInitialFrame(f.Length(version) - 1)).To(BeNil()) @@ -74,7 +74,7 @@ var _ = Describe("Retransmission queue", func() { }) It("retrieves both a CRYPTO frame and a control frame", func() { - cf := &wire.MaxDataFrame{ByteOffset: 0x42} + cf := &wire.MaxDataFrame{MaximumData: 0x42} f := &wire.CryptoFrame{Data: []byte("foobar")} q.AddInitial(f) q.AddInitial(cf) @@ -86,7 +86,7 @@ var _ = Describe("Retransmission queue", func() { It("drops all Initial frames", func() { q.AddInitial(&wire.CryptoFrame{Data: []byte("foobar")}) - q.AddInitial(&wire.MaxDataFrame{ByteOffset: 0x42}) + q.AddInitial(&wire.MaxDataFrame{MaximumData: 0x42}) q.DropPackets(protocol.EncryptionInitial) Expect(q.HasInitialData()).To(BeFalse()) Expect(q.GetInitialFrame(protocol.MaxByteCount)).To(BeNil()) @@ -100,7 +100,7 @@ var _ = Describe("Retransmission queue", func() { }) It("queues and retrieves a control frame", func() { - f := &wire.MaxDataFrame{ByteOffset: 0x42} + f := &wire.MaxDataFrame{MaximumData: 0x42} q.AddHandshake(f) Expect(q.HasHandshakeData()).To(BeTrue()) Expect(q.GetHandshakeFrame(f.Length(version) - 1)).To(BeNil()) @@ -150,7 +150,7 @@ var _ = Describe("Retransmission queue", func() { }) It("retrieves both a CRYPTO frame and a control frame", func() { - cf := &wire.MaxDataFrame{ByteOffset: 0x42} + cf := &wire.MaxDataFrame{MaximumData: 0x42} f := &wire.CryptoFrame{Data: []byte("foobar")} q.AddHandshake(f) q.AddHandshake(cf) @@ -162,7 +162,7 @@ var _ = Describe("Retransmission queue", func() { It("drops all Handshake frames", func() { q.AddHandshake(&wire.CryptoFrame{Data: []byte("foobar")}) - q.AddHandshake(&wire.MaxDataFrame{ByteOffset: 0x42}) + q.AddHandshake(&wire.MaxDataFrame{MaximumData: 0x42}) q.DropPackets(protocol.EncryptionHandshake) Expect(q.HasHandshakeData()).To(BeFalse()) Expect(q.GetHandshakeFrame(protocol.MaxByteCount)).To(BeNil()) @@ -175,7 +175,7 @@ var _ = Describe("Retransmission queue", func() { }) It("queues and retrieves a control frame", func() { - f := &wire.MaxDataFrame{ByteOffset: 0x42} + f := &wire.MaxDataFrame{MaximumData: 0x42} Expect(q.HasAppData()).To(BeFalse()) q.AddAppData(f) Expect(q.HasAppData()).To(BeTrue()) diff --git a/session.go b/session.go index acbb2cee..9162c0f9 100644 --- a/session.go +++ b/session.go @@ -1143,7 +1143,7 @@ func (s *session) handleStreamFrame(frame *wire.StreamFrame) error { } func (s *session) handleMaxDataFrame(frame *wire.MaxDataFrame) { - s.connFlowController.UpdateSendWindow(frame.ByteOffset) + s.connFlowController.UpdateSendWindow(frame.MaximumData) } func (s *session) handleMaxStreamDataFrame(frame *wire.MaxStreamDataFrame) error { diff --git a/session_test.go b/session_test.go index 1176698c..e5ceafd6 100644 --- a/session_test.go +++ b/session_test.go @@ -225,7 +225,7 @@ var _ = Describe("Session", func() { It("updates the flow control window of the connection", func() { offset := protocol.ByteCount(0x800000) connFC.EXPECT().UpdateSendWindow(offset) - sess.handleMaxDataFrame(&wire.MaxDataFrame{ByteOffset: offset}) + sess.handleMaxDataFrame(&wire.MaxDataFrame{MaximumData: offset}) }) It("ignores MAX_STREAM_DATA frames for a closed stream", func() { diff --git a/window_update_queue.go b/window_update_queue.go index 91601ebb..f3188dbe 100644 --- a/window_update_queue.go +++ b/window_update_queue.go @@ -48,7 +48,7 @@ func (q *windowUpdateQueue) QueueAll() { q.mutex.Lock() // queue a connection-level window update if q.queuedConn { - q.callback(&wire.MaxDataFrame{ByteOffset: q.connFlowController.GetWindowUpdate()}) + q.callback(&wire.MaxDataFrame{MaximumData: q.connFlowController.GetWindowUpdate()}) q.queuedConn = false } // queue all stream-level window updates diff --git a/window_update_queue_test.go b/window_update_queue_test.go index 727565f3..45869f03 100644 --- a/window_update_queue_test.go +++ b/window_update_queue_test.go @@ -94,7 +94,7 @@ var _ = Describe("Window Update Queue", func() { q.AddConnection() q.QueueAll() Expect(queuedFrames).To(Equal([]wire.Frame{ - &wire.MaxDataFrame{ByteOffset: 0x1337}, + &wire.MaxDataFrame{MaximumData: 0x1337}, })) })