{-# LANGUAGE RecordWildCards #-}

module Network.QUIC.Connection.StreamTable (
    createStream,
    findStream,
    addStream,
    delStream,
    initialRxMaxStreamData,
    setupCryptoStreams,
    clearCryptoStream,
    getCryptoStream,
) where

import Network.QUIC.Connection.Misc
import Network.QUIC.Connection.Queue
import Network.QUIC.Connection.Types
import Network.QUIC.Connector
import Network.QUIC.Imports
import Network.QUIC.Parameters
import Network.QUIC.Stream
import Network.QUIC.Types

createStream :: Connection -> StreamId -> IO Stream
createStream :: Connection -> StreamId -> IO Stream
createStream Connection
conn StreamId
sid = do
    Stream
strm <- Connection -> StreamId -> IO Stream
addStream Connection
conn StreamId
sid
    Connection -> Input -> IO ()
putInput Connection
conn (Input -> IO ()) -> Input -> IO ()
forall a b. (a -> b) -> a -> b
$ Stream -> Input
InpStream Stream
strm
    Stream -> IO Stream
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Stream
strm

findStream :: Connection -> StreamId -> IO (Maybe Stream)
findStream :: Connection -> StreamId -> IO (Maybe Stream)
findStream Connection{Recv
Buffer
Array EncryptionLevel (TVar [ReceivedPacket])
IOArray Bool Coder1RTT
IOArray EncryptionLevel Cipher
IOArray EncryptionLevel Protector
IOArray EncryptionLevel Coder
ThreadId
TVar Bool
TVar StreamId
TVar TxFlow
TVar Concurrency
TVar MigrationState
TVar CIDDB
IORef StreamId
IORef (IO ())
IORef (Bool, StreamId)
IORef RxFlow
IORef UDPSocket
IORef Microseconds
IORef VersionInfo
IORef AuthCIDs
IORef Parameters
IORef StreamTable
IORef Concurrency
IORef Negotiated
IORef CIDDB
IORef RoleInfo
Rate
OutputQLim
MigrationQ
OutputQ
CryptoQ
InputQ
VersionInfo
RecvQ
SizedBuffer
ConnState
Parameters
LDCC
Hooks
Shared
Send
DebugLogger
QLogger
connState :: ConnState
connDebugLog :: DebugLogger
connQLog :: QLogger
connHooks :: Hooks
connSend :: Send
connRecv :: Recv
connRecvQ :: RecvQ
udpSocket :: IORef UDPSocket
readers :: IORef (IO ())
mainThreadId :: ThreadId
controlRate :: Rate
roleInfo :: IORef RoleInfo
quicVersionInfo :: IORef VersionInfo
origVersionInfo :: VersionInfo
myParameters :: Parameters
myCIDDB :: IORef CIDDB
peerParameters :: IORef Parameters
peerCIDDB :: TVar CIDDB
inputQ :: InputQ
cryptoQ :: CryptoQ
outputQ :: OutputQ
outputQLim :: OutputQLim
migrationQ :: MigrationQ
shared :: Shared
delayedAckCount :: IORef StreamId
delayedAckCancel :: IORef (IO ())
peerPacketNumber :: IORef StreamId
streamTable :: IORef StreamTable
myStreamId :: TVar Concurrency
myUniStreamId :: TVar Concurrency
peerStreamId :: IORef Concurrency
peerUniStreamId :: IORef Concurrency
flowTx :: TVar TxFlow
flowRx :: IORef RxFlow
migrationState :: TVar MigrationState
minIdleTimeout :: IORef Microseconds
bytesTx :: TVar StreamId
bytesRx :: TVar StreamId
addressValidated :: TVar Bool
pendingQ :: Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: IOArray EncryptionLevel Cipher
coders :: IOArray EncryptionLevel Coder
coders1RTT :: IOArray Bool Coder1RTT
protectors :: IOArray EncryptionLevel Protector
currentKeyPhase :: IORef (Bool, StreamId)
negotiated :: IORef Negotiated
connMyAuthCIDs :: IORef AuthCIDs
connPeerAuthCIDs :: IORef AuthCIDs
connResources :: IORef (IO ())
encodeBuf :: Buffer
encryptRes :: SizedBuffer
decryptBuf :: Buffer
connLDCC :: LDCC
connState :: Connection -> ConnState
connDebugLog :: Connection -> DebugLogger
connQLog :: Connection -> QLogger
connHooks :: Connection -> Hooks
connSend :: Connection -> Send
connRecv :: Connection -> Recv
connRecvQ :: Connection -> RecvQ
udpSocket :: Connection -> IORef UDPSocket
readers :: Connection -> IORef (IO ())
mainThreadId :: Connection -> ThreadId
controlRate :: Connection -> Rate
roleInfo :: Connection -> IORef RoleInfo
quicVersionInfo :: Connection -> IORef VersionInfo
origVersionInfo :: Connection -> VersionInfo
myParameters :: Connection -> Parameters
myCIDDB :: Connection -> IORef CIDDB
peerParameters :: Connection -> IORef Parameters
peerCIDDB :: Connection -> TVar CIDDB
inputQ :: Connection -> InputQ
cryptoQ :: Connection -> CryptoQ
outputQ :: Connection -> OutputQ
outputQLim :: Connection -> OutputQLim
migrationQ :: Connection -> MigrationQ
shared :: Connection -> Shared
delayedAckCount :: Connection -> IORef StreamId
delayedAckCancel :: Connection -> IORef (IO ())
peerPacketNumber :: Connection -> IORef StreamId
streamTable :: Connection -> IORef StreamTable
myStreamId :: Connection -> TVar Concurrency
myUniStreamId :: Connection -> TVar Concurrency
peerStreamId :: Connection -> IORef Concurrency
peerUniStreamId :: Connection -> IORef Concurrency
flowTx :: Connection -> TVar TxFlow
flowRx :: Connection -> IORef RxFlow
migrationState :: Connection -> TVar MigrationState
minIdleTimeout :: Connection -> IORef Microseconds
bytesTx :: Connection -> TVar StreamId
bytesRx :: Connection -> TVar StreamId
addressValidated :: Connection -> TVar Bool
pendingQ :: Connection -> Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: Connection -> IOArray EncryptionLevel Cipher
coders :: Connection -> IOArray EncryptionLevel Coder
coders1RTT :: Connection -> IOArray Bool Coder1RTT
protectors :: Connection -> IOArray EncryptionLevel Protector
currentKeyPhase :: Connection -> IORef (Bool, StreamId)
negotiated :: Connection -> IORef Negotiated
connMyAuthCIDs :: Connection -> IORef AuthCIDs
connPeerAuthCIDs :: Connection -> IORef AuthCIDs
connResources :: Connection -> IORef (IO ())
encodeBuf :: Connection -> Buffer
encryptRes :: Connection -> SizedBuffer
decryptBuf :: Connection -> Buffer
connLDCC :: Connection -> LDCC
..} StreamId
sid = StreamId -> StreamTable -> Maybe Stream
lookupStream StreamId
sid (StreamTable -> Maybe Stream)
-> IO StreamTable -> IO (Maybe Stream)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef StreamTable -> IO StreamTable
forall a. IORef a -> IO a
readIORef IORef StreamTable
streamTable

addStream :: Connection -> StreamId -> IO Stream
addStream :: Connection -> StreamId -> IO Stream
addStream conn :: Connection
conn@Connection{Recv
Buffer
Array EncryptionLevel (TVar [ReceivedPacket])
IOArray Bool Coder1RTT
IOArray EncryptionLevel Cipher
IOArray EncryptionLevel Protector
IOArray EncryptionLevel Coder
ThreadId
TVar Bool
TVar StreamId
TVar TxFlow
TVar Concurrency
TVar MigrationState
TVar CIDDB
IORef StreamId
IORef (IO ())
IORef (Bool, StreamId)
IORef RxFlow
IORef UDPSocket
IORef Microseconds
IORef VersionInfo
IORef AuthCIDs
IORef Parameters
IORef StreamTable
IORef Concurrency
IORef Negotiated
IORef CIDDB
IORef RoleInfo
Rate
OutputQLim
MigrationQ
OutputQ
CryptoQ
InputQ
VersionInfo
RecvQ
SizedBuffer
ConnState
Parameters
LDCC
Hooks
Shared
Send
DebugLogger
QLogger
connState :: Connection -> ConnState
connDebugLog :: Connection -> DebugLogger
connQLog :: Connection -> QLogger
connHooks :: Connection -> Hooks
connSend :: Connection -> Send
connRecv :: Connection -> Recv
connRecvQ :: Connection -> RecvQ
udpSocket :: Connection -> IORef UDPSocket
readers :: Connection -> IORef (IO ())
mainThreadId :: Connection -> ThreadId
controlRate :: Connection -> Rate
roleInfo :: Connection -> IORef RoleInfo
quicVersionInfo :: Connection -> IORef VersionInfo
origVersionInfo :: Connection -> VersionInfo
myParameters :: Connection -> Parameters
myCIDDB :: Connection -> IORef CIDDB
peerParameters :: Connection -> IORef Parameters
peerCIDDB :: Connection -> TVar CIDDB
inputQ :: Connection -> InputQ
cryptoQ :: Connection -> CryptoQ
outputQ :: Connection -> OutputQ
outputQLim :: Connection -> OutputQLim
migrationQ :: Connection -> MigrationQ
shared :: Connection -> Shared
delayedAckCount :: Connection -> IORef StreamId
delayedAckCancel :: Connection -> IORef (IO ())
peerPacketNumber :: Connection -> IORef StreamId
streamTable :: Connection -> IORef StreamTable
myStreamId :: Connection -> TVar Concurrency
myUniStreamId :: Connection -> TVar Concurrency
peerStreamId :: Connection -> IORef Concurrency
peerUniStreamId :: Connection -> IORef Concurrency
flowTx :: Connection -> TVar TxFlow
flowRx :: Connection -> IORef RxFlow
migrationState :: Connection -> TVar MigrationState
minIdleTimeout :: Connection -> IORef Microseconds
bytesTx :: Connection -> TVar StreamId
bytesRx :: Connection -> TVar StreamId
addressValidated :: Connection -> TVar Bool
pendingQ :: Connection -> Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: Connection -> IOArray EncryptionLevel Cipher
coders :: Connection -> IOArray EncryptionLevel Coder
coders1RTT :: Connection -> IOArray Bool Coder1RTT
protectors :: Connection -> IOArray EncryptionLevel Protector
currentKeyPhase :: Connection -> IORef (Bool, StreamId)
negotiated :: Connection -> IORef Negotiated
connMyAuthCIDs :: Connection -> IORef AuthCIDs
connPeerAuthCIDs :: Connection -> IORef AuthCIDs
connResources :: Connection -> IORef (IO ())
encodeBuf :: Connection -> Buffer
encryptRes :: Connection -> SizedBuffer
decryptBuf :: Connection -> Buffer
connLDCC :: Connection -> LDCC
connState :: ConnState
connDebugLog :: DebugLogger
connQLog :: QLogger
connHooks :: Hooks
connSend :: Send
connRecv :: Recv
connRecvQ :: RecvQ
udpSocket :: IORef UDPSocket
readers :: IORef (IO ())
mainThreadId :: ThreadId
controlRate :: Rate
roleInfo :: IORef RoleInfo
quicVersionInfo :: IORef VersionInfo
origVersionInfo :: VersionInfo
myParameters :: Parameters
myCIDDB :: IORef CIDDB
peerParameters :: IORef Parameters
peerCIDDB :: TVar CIDDB
inputQ :: InputQ
cryptoQ :: CryptoQ
outputQ :: OutputQ
outputQLim :: OutputQLim
migrationQ :: MigrationQ
shared :: Shared
delayedAckCount :: IORef StreamId
delayedAckCancel :: IORef (IO ())
peerPacketNumber :: IORef StreamId
streamTable :: IORef StreamTable
myStreamId :: TVar Concurrency
myUniStreamId :: TVar Concurrency
peerStreamId :: IORef Concurrency
peerUniStreamId :: IORef Concurrency
flowTx :: TVar TxFlow
flowRx :: IORef RxFlow
migrationState :: TVar MigrationState
minIdleTimeout :: IORef Microseconds
bytesTx :: TVar StreamId
bytesRx :: TVar StreamId
addressValidated :: TVar Bool
pendingQ :: Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: IOArray EncryptionLevel Cipher
coders :: IOArray EncryptionLevel Coder
coders1RTT :: IOArray Bool Coder1RTT
protectors :: IOArray EncryptionLevel Protector
currentKeyPhase :: IORef (Bool, StreamId)
negotiated :: IORef Negotiated
connMyAuthCIDs :: IORef AuthCIDs
connPeerAuthCIDs :: IORef AuthCIDs
connResources :: IORef (IO ())
encodeBuf :: Buffer
encryptRes :: SizedBuffer
decryptBuf :: Buffer
connLDCC :: LDCC
..} StreamId
sid = do
    Stream
strm <-
        if Connection -> Bool
forall a. Connector a => a -> Bool
isClient Connection
conn
            then do
                Parameters
serverParams <- Connection -> IO Parameters
getPeerParameters Connection
conn
                let txLim :: StreamId
txLim = StreamId -> Parameters -> StreamId
serverInitial StreamId
sid Parameters
serverParams
                let clientParams :: Parameters
clientParams = Connection -> Parameters
getMyParameters Connection
conn
                    rxLim :: StreamId
rxLim = StreamId -> Parameters -> StreamId
clientInitial StreamId
sid Parameters
clientParams
                Connection -> StreamId -> StreamId -> StreamId -> IO Stream
newStream Connection
conn StreamId
sid StreamId
txLim StreamId
rxLim
            else do
                Parameters
clientParams <- Connection -> IO Parameters
getPeerParameters Connection
conn
                let txLim :: StreamId
txLim = StreamId -> Parameters -> StreamId
clientInitial StreamId
sid Parameters
clientParams
                    serverParams :: Parameters
serverParams = Connection -> Parameters
getMyParameters Connection
conn
                    rxLim :: StreamId
rxLim = StreamId -> Parameters -> StreamId
serverInitial StreamId
sid Parameters
serverParams
                Connection -> StreamId -> StreamId -> StreamId -> IO Stream
newStream Connection
conn StreamId
sid StreamId
txLim StreamId
rxLim
    IORef StreamTable -> (StreamTable -> StreamTable) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
atomicModifyIORef'' IORef StreamTable
streamTable ((StreamTable -> StreamTable) -> IO ())
-> (StreamTable -> StreamTable) -> IO ()
forall a b. (a -> b) -> a -> b
$ StreamId -> Stream -> StreamTable -> StreamTable
insertStream StreamId
sid Stream
strm
    Stream -> IO Stream
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Stream
strm

delStream :: Connection -> Stream -> IO ()
delStream :: Connection -> Stream -> IO ()
delStream Connection{Recv
Buffer
Array EncryptionLevel (TVar [ReceivedPacket])
IOArray Bool Coder1RTT
IOArray EncryptionLevel Cipher
IOArray EncryptionLevel Protector
IOArray EncryptionLevel Coder
ThreadId
TVar Bool
TVar StreamId
TVar TxFlow
TVar Concurrency
TVar MigrationState
TVar CIDDB
IORef StreamId
IORef (IO ())
IORef (Bool, StreamId)
IORef RxFlow
IORef UDPSocket
IORef Microseconds
IORef VersionInfo
IORef AuthCIDs
IORef Parameters
IORef StreamTable
IORef Concurrency
IORef Negotiated
IORef CIDDB
IORef RoleInfo
Rate
OutputQLim
MigrationQ
OutputQ
CryptoQ
InputQ
VersionInfo
RecvQ
SizedBuffer
ConnState
Parameters
LDCC
Hooks
Shared
Send
DebugLogger
QLogger
connState :: Connection -> ConnState
connDebugLog :: Connection -> DebugLogger
connQLog :: Connection -> QLogger
connHooks :: Connection -> Hooks
connSend :: Connection -> Send
connRecv :: Connection -> Recv
connRecvQ :: Connection -> RecvQ
udpSocket :: Connection -> IORef UDPSocket
readers :: Connection -> IORef (IO ())
mainThreadId :: Connection -> ThreadId
controlRate :: Connection -> Rate
roleInfo :: Connection -> IORef RoleInfo
quicVersionInfo :: Connection -> IORef VersionInfo
origVersionInfo :: Connection -> VersionInfo
myParameters :: Connection -> Parameters
myCIDDB :: Connection -> IORef CIDDB
peerParameters :: Connection -> IORef Parameters
peerCIDDB :: Connection -> TVar CIDDB
inputQ :: Connection -> InputQ
cryptoQ :: Connection -> CryptoQ
outputQ :: Connection -> OutputQ
outputQLim :: Connection -> OutputQLim
migrationQ :: Connection -> MigrationQ
shared :: Connection -> Shared
delayedAckCount :: Connection -> IORef StreamId
delayedAckCancel :: Connection -> IORef (IO ())
peerPacketNumber :: Connection -> IORef StreamId
streamTable :: Connection -> IORef StreamTable
myStreamId :: Connection -> TVar Concurrency
myUniStreamId :: Connection -> TVar Concurrency
peerStreamId :: Connection -> IORef Concurrency
peerUniStreamId :: Connection -> IORef Concurrency
flowTx :: Connection -> TVar TxFlow
flowRx :: Connection -> IORef RxFlow
migrationState :: Connection -> TVar MigrationState
minIdleTimeout :: Connection -> IORef Microseconds
bytesTx :: Connection -> TVar StreamId
bytesRx :: Connection -> TVar StreamId
addressValidated :: Connection -> TVar Bool
pendingQ :: Connection -> Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: Connection -> IOArray EncryptionLevel Cipher
coders :: Connection -> IOArray EncryptionLevel Coder
coders1RTT :: Connection -> IOArray Bool Coder1RTT
protectors :: Connection -> IOArray EncryptionLevel Protector
currentKeyPhase :: Connection -> IORef (Bool, StreamId)
negotiated :: Connection -> IORef Negotiated
connMyAuthCIDs :: Connection -> IORef AuthCIDs
connPeerAuthCIDs :: Connection -> IORef AuthCIDs
connResources :: Connection -> IORef (IO ())
encodeBuf :: Connection -> Buffer
encryptRes :: Connection -> SizedBuffer
decryptBuf :: Connection -> Buffer
connLDCC :: Connection -> LDCC
connState :: ConnState
connDebugLog :: DebugLogger
connQLog :: QLogger
connHooks :: Hooks
connSend :: Send
connRecv :: Recv
connRecvQ :: RecvQ
udpSocket :: IORef UDPSocket
readers :: IORef (IO ())
mainThreadId :: ThreadId
controlRate :: Rate
roleInfo :: IORef RoleInfo
quicVersionInfo :: IORef VersionInfo
origVersionInfo :: VersionInfo
myParameters :: Parameters
myCIDDB :: IORef CIDDB
peerParameters :: IORef Parameters
peerCIDDB :: TVar CIDDB
inputQ :: InputQ
cryptoQ :: CryptoQ
outputQ :: OutputQ
outputQLim :: OutputQLim
migrationQ :: MigrationQ
shared :: Shared
delayedAckCount :: IORef StreamId
delayedAckCancel :: IORef (IO ())
peerPacketNumber :: IORef StreamId
streamTable :: IORef StreamTable
myStreamId :: TVar Concurrency
myUniStreamId :: TVar Concurrency
peerStreamId :: IORef Concurrency
peerUniStreamId :: IORef Concurrency
flowTx :: TVar TxFlow
flowRx :: IORef RxFlow
migrationState :: TVar MigrationState
minIdleTimeout :: IORef Microseconds
bytesTx :: TVar StreamId
bytesRx :: TVar StreamId
addressValidated :: TVar Bool
pendingQ :: Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: IOArray EncryptionLevel Cipher
coders :: IOArray EncryptionLevel Coder
coders1RTT :: IOArray Bool Coder1RTT
protectors :: IOArray EncryptionLevel Protector
currentKeyPhase :: IORef (Bool, StreamId)
negotiated :: IORef Negotiated
connMyAuthCIDs :: IORef AuthCIDs
connPeerAuthCIDs :: IORef AuthCIDs
connResources :: IORef (IO ())
encodeBuf :: Buffer
encryptRes :: SizedBuffer
decryptBuf :: Buffer
connLDCC :: LDCC
..} Stream
strm =
    IORef StreamTable -> (StreamTable -> StreamTable) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
atomicModifyIORef'' IORef StreamTable
streamTable ((StreamTable -> StreamTable) -> IO ())
-> (StreamTable -> StreamTable) -> IO ()
forall a b. (a -> b) -> a -> b
$ StreamId -> StreamTable -> StreamTable
deleteStream (StreamId -> StreamTable -> StreamTable)
-> StreamId -> StreamTable -> StreamTable
forall a b. (a -> b) -> a -> b
$ Stream -> StreamId
streamId Stream
strm

initialRxMaxStreamData :: Connection -> StreamId -> Int
initialRxMaxStreamData :: Connection -> StreamId -> StreamId
initialRxMaxStreamData Connection
conn StreamId
sid
    | Connection -> Bool
forall a. Connector a => a -> Bool
isClient Connection
conn = StreamId -> Parameters -> StreamId
clientInitial StreamId
sid Parameters
params
    | Bool
otherwise = StreamId -> Parameters -> StreamId
serverInitial StreamId
sid Parameters
params
  where
    params :: Parameters
params = Connection -> Parameters
getMyParameters Connection
conn

clientInitial :: StreamId -> Parameters -> Int
clientInitial :: StreamId -> Parameters -> StreamId
clientInitial StreamId
sid Parameters
params
    | StreamId -> Bool
isClientInitiatedBidirectional StreamId
sid = Parameters -> StreamId
initialMaxStreamDataBidiLocal Parameters
params
    | StreamId -> Bool
isServerInitiatedBidirectional StreamId
sid = Parameters -> StreamId
initialMaxStreamDataBidiRemote Parameters
params
    -- intentionally not using isServerInitiatedUnidirectional
    | Bool
otherwise = Parameters -> StreamId
initialMaxStreamDataUni Parameters
params

serverInitial :: StreamId -> Parameters -> Int
serverInitial :: StreamId -> Parameters -> StreamId
serverInitial StreamId
sid Parameters
params
    | StreamId -> Bool
isServerInitiatedBidirectional StreamId
sid = Parameters -> StreamId
initialMaxStreamDataBidiLocal Parameters
params
    | StreamId -> Bool
isClientInitiatedBidirectional StreamId
sid = Parameters -> StreamId
initialMaxStreamDataBidiRemote Parameters
params
    -- intentionally not using isClientInitiatedUnidirectional
    | Bool
otherwise = Parameters -> StreamId
initialMaxStreamDataUni Parameters
params

----------------------------------------------------------------

setupCryptoStreams :: Connection -> IO ()
setupCryptoStreams :: Connection -> IO ()
setupCryptoStreams conn :: Connection
conn@Connection{Recv
Buffer
Array EncryptionLevel (TVar [ReceivedPacket])
IOArray Bool Coder1RTT
IOArray EncryptionLevel Cipher
IOArray EncryptionLevel Protector
IOArray EncryptionLevel Coder
ThreadId
TVar Bool
TVar StreamId
TVar TxFlow
TVar Concurrency
TVar MigrationState
TVar CIDDB
IORef StreamId
IORef (IO ())
IORef (Bool, StreamId)
IORef RxFlow
IORef UDPSocket
IORef Microseconds
IORef VersionInfo
IORef AuthCIDs
IORef Parameters
IORef StreamTable
IORef Concurrency
IORef Negotiated
IORef CIDDB
IORef RoleInfo
Rate
OutputQLim
MigrationQ
OutputQ
CryptoQ
InputQ
VersionInfo
RecvQ
SizedBuffer
ConnState
Parameters
LDCC
Hooks
Shared
Send
DebugLogger
QLogger
connState :: Connection -> ConnState
connDebugLog :: Connection -> DebugLogger
connQLog :: Connection -> QLogger
connHooks :: Connection -> Hooks
connSend :: Connection -> Send
connRecv :: Connection -> Recv
connRecvQ :: Connection -> RecvQ
udpSocket :: Connection -> IORef UDPSocket
readers :: Connection -> IORef (IO ())
mainThreadId :: Connection -> ThreadId
controlRate :: Connection -> Rate
roleInfo :: Connection -> IORef RoleInfo
quicVersionInfo :: Connection -> IORef VersionInfo
origVersionInfo :: Connection -> VersionInfo
myParameters :: Connection -> Parameters
myCIDDB :: Connection -> IORef CIDDB
peerParameters :: Connection -> IORef Parameters
peerCIDDB :: Connection -> TVar CIDDB
inputQ :: Connection -> InputQ
cryptoQ :: Connection -> CryptoQ
outputQ :: Connection -> OutputQ
outputQLim :: Connection -> OutputQLim
migrationQ :: Connection -> MigrationQ
shared :: Connection -> Shared
delayedAckCount :: Connection -> IORef StreamId
delayedAckCancel :: Connection -> IORef (IO ())
peerPacketNumber :: Connection -> IORef StreamId
streamTable :: Connection -> IORef StreamTable
myStreamId :: Connection -> TVar Concurrency
myUniStreamId :: Connection -> TVar Concurrency
peerStreamId :: Connection -> IORef Concurrency
peerUniStreamId :: Connection -> IORef Concurrency
flowTx :: Connection -> TVar TxFlow
flowRx :: Connection -> IORef RxFlow
migrationState :: Connection -> TVar MigrationState
minIdleTimeout :: Connection -> IORef Microseconds
bytesTx :: Connection -> TVar StreamId
bytesRx :: Connection -> TVar StreamId
addressValidated :: Connection -> TVar Bool
pendingQ :: Connection -> Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: Connection -> IOArray EncryptionLevel Cipher
coders :: Connection -> IOArray EncryptionLevel Coder
coders1RTT :: Connection -> IOArray Bool Coder1RTT
protectors :: Connection -> IOArray EncryptionLevel Protector
currentKeyPhase :: Connection -> IORef (Bool, StreamId)
negotiated :: Connection -> IORef Negotiated
connMyAuthCIDs :: Connection -> IORef AuthCIDs
connPeerAuthCIDs :: Connection -> IORef AuthCIDs
connResources :: Connection -> IORef (IO ())
encodeBuf :: Connection -> Buffer
encryptRes :: Connection -> SizedBuffer
decryptBuf :: Connection -> Buffer
connLDCC :: Connection -> LDCC
connState :: ConnState
connDebugLog :: DebugLogger
connQLog :: QLogger
connHooks :: Hooks
connSend :: Send
connRecv :: Recv
connRecvQ :: RecvQ
udpSocket :: IORef UDPSocket
readers :: IORef (IO ())
mainThreadId :: ThreadId
controlRate :: Rate
roleInfo :: IORef RoleInfo
quicVersionInfo :: IORef VersionInfo
origVersionInfo :: VersionInfo
myParameters :: Parameters
myCIDDB :: IORef CIDDB
peerParameters :: IORef Parameters
peerCIDDB :: TVar CIDDB
inputQ :: InputQ
cryptoQ :: CryptoQ
outputQ :: OutputQ
outputQLim :: OutputQLim
migrationQ :: MigrationQ
shared :: Shared
delayedAckCount :: IORef StreamId
delayedAckCancel :: IORef (IO ())
peerPacketNumber :: IORef StreamId
streamTable :: IORef StreamTable
myStreamId :: TVar Concurrency
myUniStreamId :: TVar Concurrency
peerStreamId :: IORef Concurrency
peerUniStreamId :: IORef Concurrency
flowTx :: TVar TxFlow
flowRx :: IORef RxFlow
migrationState :: TVar MigrationState
minIdleTimeout :: IORef Microseconds
bytesTx :: TVar StreamId
bytesRx :: TVar StreamId
addressValidated :: TVar Bool
pendingQ :: Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: IOArray EncryptionLevel Cipher
coders :: IOArray EncryptionLevel Coder
coders1RTT :: IOArray Bool Coder1RTT
protectors :: IOArray EncryptionLevel Protector
currentKeyPhase :: IORef (Bool, StreamId)
negotiated :: IORef Negotiated
connMyAuthCIDs :: IORef AuthCIDs
connPeerAuthCIDs :: IORef AuthCIDs
connResources :: IORef (IO ())
encodeBuf :: Buffer
encryptRes :: SizedBuffer
decryptBuf :: Buffer
connLDCC :: LDCC
..} = do
    StreamTable
stbl0 <- IORef StreamTable -> IO StreamTable
forall a. IORef a -> IO a
readIORef IORef StreamTable
streamTable
    StreamTable
stbl <- Connection -> StreamTable -> IO StreamTable
insertCryptoStreams Connection
conn StreamTable
stbl0
    IORef StreamTable -> StreamTable -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef IORef StreamTable
streamTable StreamTable
stbl

clearCryptoStream :: Connection -> EncryptionLevel -> IO ()
clearCryptoStream :: Connection -> EncryptionLevel -> IO ()
clearCryptoStream Connection{Recv
Buffer
Array EncryptionLevel (TVar [ReceivedPacket])
IOArray Bool Coder1RTT
IOArray EncryptionLevel Cipher
IOArray EncryptionLevel Protector
IOArray EncryptionLevel Coder
ThreadId
TVar Bool
TVar StreamId
TVar TxFlow
TVar Concurrency
TVar MigrationState
TVar CIDDB
IORef StreamId
IORef (IO ())
IORef (Bool, StreamId)
IORef RxFlow
IORef UDPSocket
IORef Microseconds
IORef VersionInfo
IORef AuthCIDs
IORef Parameters
IORef StreamTable
IORef Concurrency
IORef Negotiated
IORef CIDDB
IORef RoleInfo
Rate
OutputQLim
MigrationQ
OutputQ
CryptoQ
InputQ
VersionInfo
RecvQ
SizedBuffer
ConnState
Parameters
LDCC
Hooks
Shared
Send
DebugLogger
QLogger
connState :: Connection -> ConnState
connDebugLog :: Connection -> DebugLogger
connQLog :: Connection -> QLogger
connHooks :: Connection -> Hooks
connSend :: Connection -> Send
connRecv :: Connection -> Recv
connRecvQ :: Connection -> RecvQ
udpSocket :: Connection -> IORef UDPSocket
readers :: Connection -> IORef (IO ())
mainThreadId :: Connection -> ThreadId
controlRate :: Connection -> Rate
roleInfo :: Connection -> IORef RoleInfo
quicVersionInfo :: Connection -> IORef VersionInfo
origVersionInfo :: Connection -> VersionInfo
myParameters :: Connection -> Parameters
myCIDDB :: Connection -> IORef CIDDB
peerParameters :: Connection -> IORef Parameters
peerCIDDB :: Connection -> TVar CIDDB
inputQ :: Connection -> InputQ
cryptoQ :: Connection -> CryptoQ
outputQ :: Connection -> OutputQ
outputQLim :: Connection -> OutputQLim
migrationQ :: Connection -> MigrationQ
shared :: Connection -> Shared
delayedAckCount :: Connection -> IORef StreamId
delayedAckCancel :: Connection -> IORef (IO ())
peerPacketNumber :: Connection -> IORef StreamId
streamTable :: Connection -> IORef StreamTable
myStreamId :: Connection -> TVar Concurrency
myUniStreamId :: Connection -> TVar Concurrency
peerStreamId :: Connection -> IORef Concurrency
peerUniStreamId :: Connection -> IORef Concurrency
flowTx :: Connection -> TVar TxFlow
flowRx :: Connection -> IORef RxFlow
migrationState :: Connection -> TVar MigrationState
minIdleTimeout :: Connection -> IORef Microseconds
bytesTx :: Connection -> TVar StreamId
bytesRx :: Connection -> TVar StreamId
addressValidated :: Connection -> TVar Bool
pendingQ :: Connection -> Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: Connection -> IOArray EncryptionLevel Cipher
coders :: Connection -> IOArray EncryptionLevel Coder
coders1RTT :: Connection -> IOArray Bool Coder1RTT
protectors :: Connection -> IOArray EncryptionLevel Protector
currentKeyPhase :: Connection -> IORef (Bool, StreamId)
negotiated :: Connection -> IORef Negotiated
connMyAuthCIDs :: Connection -> IORef AuthCIDs
connPeerAuthCIDs :: Connection -> IORef AuthCIDs
connResources :: Connection -> IORef (IO ())
encodeBuf :: Connection -> Buffer
encryptRes :: Connection -> SizedBuffer
decryptBuf :: Connection -> Buffer
connLDCC :: Connection -> LDCC
connState :: ConnState
connDebugLog :: DebugLogger
connQLog :: QLogger
connHooks :: Hooks
connSend :: Send
connRecv :: Recv
connRecvQ :: RecvQ
udpSocket :: IORef UDPSocket
readers :: IORef (IO ())
mainThreadId :: ThreadId
controlRate :: Rate
roleInfo :: IORef RoleInfo
quicVersionInfo :: IORef VersionInfo
origVersionInfo :: VersionInfo
myParameters :: Parameters
myCIDDB :: IORef CIDDB
peerParameters :: IORef Parameters
peerCIDDB :: TVar CIDDB
inputQ :: InputQ
cryptoQ :: CryptoQ
outputQ :: OutputQ
outputQLim :: OutputQLim
migrationQ :: MigrationQ
shared :: Shared
delayedAckCount :: IORef StreamId
delayedAckCancel :: IORef (IO ())
peerPacketNumber :: IORef StreamId
streamTable :: IORef StreamTable
myStreamId :: TVar Concurrency
myUniStreamId :: TVar Concurrency
peerStreamId :: IORef Concurrency
peerUniStreamId :: IORef Concurrency
flowTx :: TVar TxFlow
flowRx :: IORef RxFlow
migrationState :: TVar MigrationState
minIdleTimeout :: IORef Microseconds
bytesTx :: TVar StreamId
bytesRx :: TVar StreamId
addressValidated :: TVar Bool
pendingQ :: Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: IOArray EncryptionLevel Cipher
coders :: IOArray EncryptionLevel Coder
coders1RTT :: IOArray Bool Coder1RTT
protectors :: IOArray EncryptionLevel Protector
currentKeyPhase :: IORef (Bool, StreamId)
negotiated :: IORef Negotiated
connMyAuthCIDs :: IORef AuthCIDs
connPeerAuthCIDs :: IORef AuthCIDs
connResources :: IORef (IO ())
encodeBuf :: Buffer
encryptRes :: SizedBuffer
decryptBuf :: Buffer
connLDCC :: LDCC
..} EncryptionLevel
lvl =
    IORef StreamTable -> (StreamTable -> StreamTable) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
atomicModifyIORef'' IORef StreamTable
streamTable ((StreamTable -> StreamTable) -> IO ())
-> (StreamTable -> StreamTable) -> IO ()
forall a b. (a -> b) -> a -> b
$ EncryptionLevel -> StreamTable -> StreamTable
deleteCryptoStream EncryptionLevel
lvl

----------------------------------------------------------------

getCryptoStream :: Connection -> EncryptionLevel -> IO (Maybe Stream)
getCryptoStream :: Connection -> EncryptionLevel -> IO (Maybe Stream)
getCryptoStream Connection{Recv
Buffer
Array EncryptionLevel (TVar [ReceivedPacket])
IOArray Bool Coder1RTT
IOArray EncryptionLevel Cipher
IOArray EncryptionLevel Protector
IOArray EncryptionLevel Coder
ThreadId
TVar Bool
TVar StreamId
TVar TxFlow
TVar Concurrency
TVar MigrationState
TVar CIDDB
IORef StreamId
IORef (IO ())
IORef (Bool, StreamId)
IORef RxFlow
IORef UDPSocket
IORef Microseconds
IORef VersionInfo
IORef AuthCIDs
IORef Parameters
IORef StreamTable
IORef Concurrency
IORef Negotiated
IORef CIDDB
IORef RoleInfo
Rate
OutputQLim
MigrationQ
OutputQ
CryptoQ
InputQ
VersionInfo
RecvQ
SizedBuffer
ConnState
Parameters
LDCC
Hooks
Shared
Send
DebugLogger
QLogger
connState :: Connection -> ConnState
connDebugLog :: Connection -> DebugLogger
connQLog :: Connection -> QLogger
connHooks :: Connection -> Hooks
connSend :: Connection -> Send
connRecv :: Connection -> Recv
connRecvQ :: Connection -> RecvQ
udpSocket :: Connection -> IORef UDPSocket
readers :: Connection -> IORef (IO ())
mainThreadId :: Connection -> ThreadId
controlRate :: Connection -> Rate
roleInfo :: Connection -> IORef RoleInfo
quicVersionInfo :: Connection -> IORef VersionInfo
origVersionInfo :: Connection -> VersionInfo
myParameters :: Connection -> Parameters
myCIDDB :: Connection -> IORef CIDDB
peerParameters :: Connection -> IORef Parameters
peerCIDDB :: Connection -> TVar CIDDB
inputQ :: Connection -> InputQ
cryptoQ :: Connection -> CryptoQ
outputQ :: Connection -> OutputQ
outputQLim :: Connection -> OutputQLim
migrationQ :: Connection -> MigrationQ
shared :: Connection -> Shared
delayedAckCount :: Connection -> IORef StreamId
delayedAckCancel :: Connection -> IORef (IO ())
peerPacketNumber :: Connection -> IORef StreamId
streamTable :: Connection -> IORef StreamTable
myStreamId :: Connection -> TVar Concurrency
myUniStreamId :: Connection -> TVar Concurrency
peerStreamId :: Connection -> IORef Concurrency
peerUniStreamId :: Connection -> IORef Concurrency
flowTx :: Connection -> TVar TxFlow
flowRx :: Connection -> IORef RxFlow
migrationState :: Connection -> TVar MigrationState
minIdleTimeout :: Connection -> IORef Microseconds
bytesTx :: Connection -> TVar StreamId
bytesRx :: Connection -> TVar StreamId
addressValidated :: Connection -> TVar Bool
pendingQ :: Connection -> Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: Connection -> IOArray EncryptionLevel Cipher
coders :: Connection -> IOArray EncryptionLevel Coder
coders1RTT :: Connection -> IOArray Bool Coder1RTT
protectors :: Connection -> IOArray EncryptionLevel Protector
currentKeyPhase :: Connection -> IORef (Bool, StreamId)
negotiated :: Connection -> IORef Negotiated
connMyAuthCIDs :: Connection -> IORef AuthCIDs
connPeerAuthCIDs :: Connection -> IORef AuthCIDs
connResources :: Connection -> IORef (IO ())
encodeBuf :: Connection -> Buffer
encryptRes :: Connection -> SizedBuffer
decryptBuf :: Connection -> Buffer
connLDCC :: Connection -> LDCC
connState :: ConnState
connDebugLog :: DebugLogger
connQLog :: QLogger
connHooks :: Hooks
connSend :: Send
connRecv :: Recv
connRecvQ :: RecvQ
udpSocket :: IORef UDPSocket
readers :: IORef (IO ())
mainThreadId :: ThreadId
controlRate :: Rate
roleInfo :: IORef RoleInfo
quicVersionInfo :: IORef VersionInfo
origVersionInfo :: VersionInfo
myParameters :: Parameters
myCIDDB :: IORef CIDDB
peerParameters :: IORef Parameters
peerCIDDB :: TVar CIDDB
inputQ :: InputQ
cryptoQ :: CryptoQ
outputQ :: OutputQ
outputQLim :: OutputQLim
migrationQ :: MigrationQ
shared :: Shared
delayedAckCount :: IORef StreamId
delayedAckCancel :: IORef (IO ())
peerPacketNumber :: IORef StreamId
streamTable :: IORef StreamTable
myStreamId :: TVar Concurrency
myUniStreamId :: TVar Concurrency
peerStreamId :: IORef Concurrency
peerUniStreamId :: IORef Concurrency
flowTx :: TVar TxFlow
flowRx :: IORef RxFlow
migrationState :: TVar MigrationState
minIdleTimeout :: IORef Microseconds
bytesTx :: TVar StreamId
bytesRx :: TVar StreamId
addressValidated :: TVar Bool
pendingQ :: Array EncryptionLevel (TVar [ReceivedPacket])
ciphers :: IOArray EncryptionLevel Cipher
coders :: IOArray EncryptionLevel Coder
coders1RTT :: IOArray Bool Coder1RTT
protectors :: IOArray EncryptionLevel Protector
currentKeyPhase :: IORef (Bool, StreamId)
negotiated :: IORef Negotiated
connMyAuthCIDs :: IORef AuthCIDs
connPeerAuthCIDs :: IORef AuthCIDs
connResources :: IORef (IO ())
encodeBuf :: Buffer
encryptRes :: SizedBuffer
decryptBuf :: Buffer
connLDCC :: LDCC
..} EncryptionLevel
lvl =
    EncryptionLevel -> StreamTable -> Maybe Stream
lookupCryptoStream EncryptionLevel
lvl (StreamTable -> Maybe Stream)
-> IO StreamTable -> IO (Maybe Stream)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef StreamTable -> IO StreamTable
forall a. IORef a -> IO a
readIORef IORef StreamTable
streamTable