Browse Source

rename the BLOCKED from to DATA_BLOCKED

Marten Seemann 9 months ago
parent
commit
387613aa20

+ 1 - 1
framer_test.go

@@ -56,7 +56,7 @@ var _ = Describe("Stream Framer", func() {
 
 		It("adds the right number of frames", func() {
 			maxSize := protocol.ByteCount(1000)
-			bf := &wire.BlockedFrame{Offset: 0x1337}
+			bf := &wire.DataBlockedFrame{DataLimit: 0x1337}
 			bfLen := bf.Length(version)
 			numFrames := int(maxSize / bfLen) // max number of frames that fit into maxSize
 			for i := 0; i < numFrames+1; i++ {

+ 1 - 1
internal/ackhandler/retransmittable_test.go

@@ -11,7 +11,7 @@ import (
 var _ = Describe("retransmittable frames", func() {
 	for fl, el := range map[wire.Frame]bool{
 		&wire.AckFrame{}:             false,
-		&wire.BlockedFrame{}:         true,
+		&wire.DataBlockedFrame{}:     true,
 		&wire.ConnectionCloseFrame{}: true,
 		&wire.PingFrame{}:            true,
 		&wire.ResetStreamFrame{}:     true,

+ 0 - 39
internal/wire/blocked_frame.go

@@ -1,39 +0,0 @@
-package wire
-
-import (
-	"bytes"
-
-	"github.com/lucas-clemente/quic-go/internal/protocol"
-	"github.com/lucas-clemente/quic-go/internal/utils"
-)
-
-// A BlockedFrame is a BLOCKED frame
-type BlockedFrame struct {
-	Offset protocol.ByteCount
-}
-
-// parseBlockedFrame parses a BLOCKED frame
-func parseBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*BlockedFrame, error) {
-	if _, err := r.ReadByte(); err != nil {
-		return nil, err
-	}
-	offset, err := utils.ReadVarInt(r)
-	if err != nil {
-		return nil, err
-	}
-	return &BlockedFrame{
-		Offset: protocol.ByteCount(offset),
-	}, nil
-}
-
-func (f *BlockedFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
-	typeByte := uint8(0x08)
-	b.WriteByte(typeByte)
-	utils.WriteVarInt(b, uint64(f.Offset))
-	return nil
-}
-
-// Length of a written frame
-func (f *BlockedFrame) Length(version protocol.VersionNumber) protocol.ByteCount {
-	return 1 + utils.VarIntLen(uint64(f.Offset))
-}

+ 38 - 0
internal/wire/data_blocked_frame.go

@@ -0,0 +1,38 @@
+package wire
+
+import (
+	"bytes"
+
+	"github.com/lucas-clemente/quic-go/internal/protocol"
+	"github.com/lucas-clemente/quic-go/internal/utils"
+)
+
+// A DataBlockedFrame is a DATA_BLOCKED frame
+type DataBlockedFrame struct {
+	DataLimit protocol.ByteCount
+}
+
+func parseDataBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*DataBlockedFrame, error) {
+	if _, err := r.ReadByte(); err != nil {
+		return nil, err
+	}
+	offset, err := utils.ReadVarInt(r)
+	if err != nil {
+		return nil, err
+	}
+	return &DataBlockedFrame{
+		DataLimit: protocol.ByteCount(offset),
+	}, nil
+}
+
+func (f *DataBlockedFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
+	typeByte := uint8(0x08)
+	b.WriteByte(typeByte)
+	utils.WriteVarInt(b, uint64(f.DataLimit))
+	return nil
+}
+
+// Length of a written frame
+func (f *DataBlockedFrame) Length(version protocol.VersionNumber) protocol.ByteCount {
+	return 1 + utils.VarIntLen(uint64(f.DataLimit))
+}

+ 7 - 7
internal/wire/blocked_frame_test.go

@@ -11,25 +11,25 @@ import (
 	. "github.com/onsi/gomega"
 )
 
-var _ = Describe("BLOCKED frame", func() {
+var _ = Describe("DATA_BLOCKED frame", func() {
 	Context("when parsing", func() {
 		It("accepts sample frame", func() {
 			data := []byte{0x08}
 			data = append(data, encodeVarInt(0x12345678)...)
 			b := bytes.NewReader(data)
-			frame, err := parseBlockedFrame(b, versionIETFFrames)
+			frame, err := parseDataBlockedFrame(b, versionIETFFrames)
 			Expect(err).ToNot(HaveOccurred())
-			Expect(frame.Offset).To(Equal(protocol.ByteCount(0x12345678)))
+			Expect(frame.DataLimit).To(Equal(protocol.ByteCount(0x12345678)))
 			Expect(b.Len()).To(BeZero())
 		})
 
 		It("errors on EOFs", func() {
 			data := []byte{0x08}
 			data = append(data, encodeVarInt(0x12345678)...)
-			_, err := parseBlockedFrame(bytes.NewReader(data), versionIETFFrames)
+			_, err := parseDataBlockedFrame(bytes.NewReader(data), versionIETFFrames)
 			Expect(err).ToNot(HaveOccurred())
 			for i := range data {
-				_, err := parseBlockedFrame(bytes.NewReader(data[:i]), versionIETFFrames)
+				_, err := parseDataBlockedFrame(bytes.NewReader(data[:i]), versionIETFFrames)
 				Expect(err).To(MatchError(io.EOF))
 			}
 		})
@@ -38,7 +38,7 @@ var _ = Describe("BLOCKED frame", func() {
 	Context("when writing", func() {
 		It("writes a sample frame", func() {
 			b := &bytes.Buffer{}
-			frame := BlockedFrame{Offset: 0xdeadbeef}
+			frame := DataBlockedFrame{DataLimit: 0xdeadbeef}
 			err := frame.Write(b, protocol.VersionWhatever)
 			Expect(err).ToNot(HaveOccurred())
 			expected := []byte{0x08}
@@ -47,7 +47,7 @@ var _ = Describe("BLOCKED frame", func() {
 		})
 
 		It("has the correct min length", func() {
-			frame := BlockedFrame{Offset: 0x12345}
+			frame := DataBlockedFrame{DataLimit: 0x12345}
 			Expect(frame.Length(versionIETFFrames)).To(Equal(1 + utils.VarIntLen(0x12345)))
 		})
 	})

+ 1 - 1
internal/wire/frame_parser.go

@@ -63,7 +63,7 @@ func parseFrame(r *bytes.Reader, typeByte byte, v protocol.VersionNumber) (Frame
 	case 0x7:
 		frame, err = parsePingFrame(r, v)
 	case 0x8:
-		frame, err = parseBlockedFrame(r, v)
+		frame, err = parseDataBlockedFrame(r, v)
 		if err != nil {
 			err = qerr.Error(qerr.InvalidBlockedData, err.Error())
 		}

+ 2 - 2
internal/wire/frame_parser_test.go

@@ -107,8 +107,8 @@ var _ = Describe("Frame parsing", func() {
 		Expect(frame).To(Equal(f))
 	})
 
-	It("unpacks connection-level BLOCKED frames", func() {
-		f := &BlockedFrame{Offset: 0x1234}
+	It("unpacks DATA_BLOCKED frames", func() {
+		f := &DataBlockedFrame{DataLimit: 0x1234}
 		buf := &bytes.Buffer{}
 		err := f.Write(buf, versionIETFFrames)
 		Expect(err).ToNot(HaveOccurred())

+ 2 - 2
packet_unpacker_test.go

@@ -57,10 +57,10 @@ var _ = Describe("Packet Unpacker", func() {
 	It("unpacks the frames", func() {
 		buf := &bytes.Buffer{}
 		(&wire.PingFrame{}).Write(buf, protocol.VersionWhatever)
-		(&wire.BlockedFrame{}).Write(buf, protocol.VersionWhatever)
+		(&wire.DataBlockedFrame{}).Write(buf, protocol.VersionWhatever)
 		aead.EXPECT().Open1RTT(gomock.Any(), gomock.Any(), hdr.PacketNumber, hdr.Raw).Return(buf.Bytes(), nil)
 		packet, err := unpacker.Unpack(hdr.Raw, hdr, nil)
 		Expect(err).ToNot(HaveOccurred())
-		Expect(packet.frames).To(Equal([]wire.Frame{&wire.PingFrame{}, &wire.BlockedFrame{}}))
+		Expect(packet.frames).To(Equal([]wire.Frame{&wire.PingFrame{}, &wire.DataBlockedFrame{}}))
 	})
 })

+ 2 - 2
session.go

@@ -551,7 +551,7 @@ func (s *session) handleFrames(fs []wire.Frame, encLevel protocol.EncryptionLeve
 			err = s.handleMaxStreamDataFrame(frame)
 		case *wire.MaxStreamIDFrame:
 			err = s.handleMaxStreamIDFrame(frame)
-		case *wire.BlockedFrame:
+		case *wire.DataBlockedFrame:
 		case *wire.StreamBlockedFrame:
 		case *wire.StreamIDBlockedFrame:
 		case *wire.StopSendingFrame:
@@ -893,7 +893,7 @@ func (s *session) sendProbePacket() error {
 
 func (s *session) sendPacket() (bool, error) {
 	if isBlocked, offset := s.connFlowController.IsNewlyBlocked(); isBlocked {
-		s.framer.QueueControlFrame(&wire.BlockedFrame{Offset: offset})
+		s.framer.QueueControlFrame(&wire.DataBlockedFrame{DataLimit: offset})
 	}
 	s.windowUpdateQueue.QueueAll()
 

+ 2 - 2
session_test.go

@@ -306,7 +306,7 @@ var _ = Describe("Session", func() {
 		})
 
 		It("handles BLOCKED frames", func() {
-			err := sess.handleFrames([]wire.Frame{&wire.BlockedFrame{}}, protocol.EncryptionUnspecified)
+			err := sess.handleFrames([]wire.Frame{&wire.DataBlockedFrame{}}, protocol.EncryptionUnspecified)
 			Expect(err).NotTo(HaveOccurred())
 		})
 
@@ -598,7 +598,7 @@ var _ = Describe("Session", func() {
 			Expect(err).NotTo(HaveOccurred())
 			Expect(sent).To(BeTrue())
 			frames, _ := sess.framer.AppendControlFrames(nil, 1000)
-			Expect(frames).To(Equal([]wire.Frame{&wire.BlockedFrame{Offset: 1337}}))
+			Expect(frames).To(Equal([]wire.Frame{&wire.DataBlockedFrame{DataLimit: 1337}}))
 		})
 
 		It("sends a retransmission and a regular packet in the same run", func() {