mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
implement parsing and writing of the new STREAM frames
This commit is contained in:
parent
1a515d1371
commit
11f746a183
14 changed files with 1015 additions and 601 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
type streamFramer struct {
|
||||
streamsMap *streamsMap
|
||||
cryptoStream streamI
|
||||
version protocol.VersionNumber
|
||||
|
||||
connFlowController flowcontrol.ConnectionFlowController
|
||||
|
||||
|
@ -20,11 +21,13 @@ func newStreamFramer(
|
|||
cryptoStream streamI,
|
||||
streamsMap *streamsMap,
|
||||
cfc flowcontrol.ConnectionFlowController,
|
||||
v protocol.VersionNumber,
|
||||
) *streamFramer {
|
||||
return &streamFramer{
|
||||
streamsMap: streamsMap,
|
||||
cryptoStream: cryptoStream,
|
||||
connFlowController: cfc,
|
||||
version: v,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +66,7 @@ func (f *streamFramer) PopCryptoStreamFrame(maxLen protocol.ByteCount) *wire.Str
|
|||
StreamID: f.cryptoStream.StreamID(),
|
||||
Offset: f.cryptoStream.GetWriteOffset(),
|
||||
}
|
||||
frameHeaderBytes, _ := frame.MinLength(protocol.VersionWhatever) // can never error
|
||||
frameHeaderBytes, _ := frame.MinLength(f.version) // can never error
|
||||
frame.Data = f.cryptoStream.GetDataForWriting(maxLen - frameHeaderBytes)
|
||||
return frame
|
||||
}
|
||||
|
@ -73,7 +76,7 @@ func (f *streamFramer) maybePopFramesForRetransmission(maxLen protocol.ByteCount
|
|||
frame := f.retransmissionQueue[0]
|
||||
frame.DataLenPresent = true
|
||||
|
||||
frameHeaderLen, _ := frame.MinLength(protocol.VersionWhatever) // can never error
|
||||
frameHeaderLen, _ := frame.MinLength(f.version) // can never error
|
||||
if currentLen+frameHeaderLen >= maxLen {
|
||||
break
|
||||
}
|
||||
|
@ -106,7 +109,7 @@ func (f *streamFramer) maybePopNormalFrames(maxBytes protocol.ByteCount) (res []
|
|||
frame.StreamID = s.StreamID()
|
||||
frame.Offset = s.GetWriteOffset()
|
||||
// not perfect, but thread-safe since writeOffset is only written when getting data
|
||||
frameHeaderBytes, _ := frame.MinLength(protocol.VersionWhatever) // can never error
|
||||
frameHeaderBytes, _ := frame.MinLength(f.version) // can never error
|
||||
if currentLen+frameHeaderBytes > maxBytes {
|
||||
return false, nil // theoretically, we could find another stream that fits, but this is quite unlikely, so we stop here
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue