-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | QUIC -- -- Library for QUIC: A UDP-Based Multiplexed and Secure Transport @package quic @version 0.2.4 -- | This main module provides APIs for QUIC. -- -- The -threaded option must be specified to GHC to use this library. module Network.QUIC -- | A quic connection to carry multiple streams. data Connection -- | Closing a connection with an application protocol error. abortConnection :: Connection -> ApplicationProtocolError -> ReasonPhrase -> IO () -- | An abstract data type for streams. data Stream -- | Stream identifier. This should be 62-bit interger. On 32-bit machines, -- the total number of stream identifiers is limited. type StreamId = Int -- | Getting stream identifier. streamId :: Stream -> StreamId -- | Checking if a stream is client-initiated bidirectional. isClientInitiatedBidirectional :: StreamId -> Bool -- | Checking if a stream is server-initiated bidirectional. isServerInitiatedBidirectional :: StreamId -> Bool -- | Checking if a stream is client-initiated unidirectional. isClientInitiatedUnidirectional :: StreamId -> Bool -- | Checking if a stream is server-initiated unidirectional. isServerInitiatedUnidirectional :: StreamId -> Bool -- | Creating a bidirectional stream. stream :: Connection -> IO Stream -- | Creating a unidirectional stream. unidirectionalStream :: Connection -> IO Stream -- | Accepting a stream initiated by the peer. acceptStream :: Connection -> IO Stream -- | Closing a stream without an error. This sends FIN if necessary. closeStream :: Stream -> IO () -- | Sending FIN in a stream. closeStream should be called later. shutdownStream :: Stream -> IO () -- | Closing a stream with an error code. This sends RESET_STREAM to the -- peer. This is an alternative of closeStream. resetStream :: Stream -> ApplicationProtocolError -> IO () -- | Asking the peer to stop sending. This sends STOP_SENDING to the peer -- and it will send RESET_STREAM back. closeStream should be -- called later. stopStream :: Stream -> ApplicationProtocolError -> IO () -- | Receiving data in the stream. In the case where a FIN is received an -- empty bytestring is returned. recvStream :: Stream -> Int -> IO ByteString -- | Sending data in the stream. sendStream :: Stream -> ByteString -> IO () -- | Sending a list of data in the stream. sendStreamMany :: Stream -> [ByteString] -> IO () -- | Information about a connection. data ConnectionInfo -- | Getting information about a connection. getConnectionInfo :: Connection -> IO ConnectionInfo version :: ConnectionInfo -> Version cipher :: ConnectionInfo -> Cipher alpn :: ConnectionInfo -> Maybe ByteString handshakeMode :: ConnectionInfo -> HandshakeMode13 retry :: ConnectionInfo -> Bool localSockAddr :: ConnectionInfo -> SockAddr remoteSockAddr :: ConnectionInfo -> SockAddr localCID :: ConnectionInfo -> CID remoteCID :: ConnectionInfo -> CID -- | Statistics of a connection. data ConnectionStats -- | Getting statistics of a connection. getConnectionStats :: Connection -> IO ConnectionStats txBytes :: ConnectionStats -> Int rxBytes :: ConnectionStats -> Int -- | Waiting until 0-RTT data can be sent. wait0RTTReady :: Connection -> IO () -- | Waiting until 1-RTT data can be sent. wait1RTTReady :: Connection -> IO () -- | For clients, waiting until HANDSHAKE_DONE is received. For servers, -- waiting until a TLS stack reports that the handshake is complete. waitEstablished :: Connection -> IO () -- | User level exceptions for QUIC. data QUICException ConnectionIsClosed :: QUICException TransportErrorIsReceived :: TransportError -> ReasonPhrase -> QUICException TransportErrorIsSent :: TransportError -> ReasonPhrase -> QUICException ApplicationProtocolErrorIsReceived :: ApplicationProtocolError -> ReasonPhrase -> QUICException ApplicationProtocolErrorIsSent :: ApplicationProtocolError -> ReasonPhrase -> QUICException ConnectionIsTimeout :: String -> QUICException ConnectionIsReset :: QUICException StreamIsClosed :: QUICException HandshakeFailed :: AlertDescription -> QUICException VersionIsUnknown :: Word32 -> QUICException NoVersionIsSpecified :: QUICException VersionNegotiationFailed :: QUICException BadThingHappen :: SomeException -> QUICException -- | Transport errors of QUIC. newtype TransportError TransportError :: Int -> TransportError pattern NoError :: TransportError pattern InternalError :: TransportError pattern ConnectionRefused :: TransportError pattern FlowControlError :: TransportError pattern StreamLimitError :: TransportError pattern StreamStateError :: TransportError pattern FinalSizeError :: TransportError pattern FrameEncodingError :: TransportError pattern TransportParameterError :: TransportError pattern ConnectionIdLimitError :: TransportError pattern ProtocolViolation :: TransportError pattern InvalidToken :: TransportError pattern ApplicationError :: TransportError pattern CryptoBufferExceeded :: TransportError pattern KeyUpdateError :: TransportError pattern AeadLimitReached :: TransportError pattern NoViablePath :: TransportError -- | Converting a TLS alert to a corresponding transport error. cryptoError :: AlertDescription -> TransportError -- | Application protocol errors of QUIC. newtype ApplicationProtocolError ApplicationProtocolError :: Int -> ApplicationProtocolError -- | This main module provides APIs for QUIC clients. When a new better -- network interface is up, migration is done automatically. module Network.QUIC.Client -- | Running a QUIC client. A UDP socket is created according to -- ccServerName and ccPortName. -- -- If ccAutoMigration is True, a unconnected socket is -- made. Otherwise, a connected socket is made. Use the migrate -- API for the connected socket. run :: ClientConfig -> (Connection -> IO a) -> IO a -- | Client configuration. data ClientConfig -- | The default value for client configuration. defaultClientConfig :: ClientConfig -- | Used to create a socket and SNI for TLS. ccServerName :: ClientConfig -> HostName -- | Used to create a socket. ccPortName :: ClientConfig -> ServiceName -- | An ALPN provider. ccALPN :: ClientConfig -> Version -> IO (Maybe [ByteString]) -- | Use 0-RTT on the 2nd connection if possible. client original ccUse0RTT :: ClientConfig -> Bool -- | Use resumption on the 2nd connection if possible. ccResumption :: ClientConfig -> ResumptionInfo -- | Cipher candidates defined in TLS 1.3. ccCiphers :: ClientConfig -> [Cipher] -- | Key exchange group candidates defined in TLS 1.3. ccGroups :: ClientConfig -> [Group] -- | Compatible versions with ccVersion in the preferred order. ccVersions :: ClientConfig -> [Version] -- | Authenticating a server based on its certificate. ccValidate :: ClientConfig -> Bool -- | Information about resumption data ResumptionInfo -- | Getting information about resumption. getResumptionInfo :: Connection -> IO ResumptionInfo -- | Is resumption possible? isResumptionPossible :: ResumptionInfo -> Bool -- | Is 0RTT possible? is0RTTPossible :: ResumptionInfo -> Bool -- | Creating a new socket and execute a path validation with a new -- connection ID. migrate :: Connection -> IO Bool -- | This main module provides APIs for QUIC servers. module Network.QUIC.Server -- | Running a QUIC server. The action is executed with a new connection in -- a new lightweight thread. run :: ServerConfig -> (Connection -> IO ()) -> IO () -- | Running a QUIC server. The action is executed with a new connection in -- a new lightweight thread. runWithSockets :: [Socket] -> ServerConfig -> (Connection -> IO ()) -> IO () -- | Stopping the base thread of the server. stop :: Connection -> IO () -- | Server configuration. data ServerConfig -- | The default value for server configuration. defaultServerConfig :: ServerConfig -- | Server addresses assigned to used network interfaces. scAddresses :: ServerConfig -> [(IP, PortNumber)] -- | ALPN handler. scALPN :: ServerConfig -> Maybe (Version -> [ByteString] -> IO ByteString) -- | Requiring QUIC retry. scRequireRetry :: ServerConfig -> Bool -- | Use 0-RTT on the 2nd connection if possible. server original scUse0RTT :: ServerConfig -> Bool -- | Cipher candidates defined in TLS 1.3. scCiphers :: ServerConfig -> [Cipher] -- | Key exchange group candidates defined in TLS 1.3. scGroups :: ServerConfig -> [Group] -- | Fully-Deployed Versions in the preferred order. scVersions :: ServerConfig -> [Version] -- | Server certificate information. scCredentials :: ServerConfig -> Credentials -- | A session manager of TLS 1.3. scSessionManager :: ServerConfig -> SessionManager -- | Getting a certificate chain of a client. clientCertificateChain :: Connection -> IO (Maybe CertificateChain) module Network.QUIC.Internal -- | Hooks. data Hooks Hooks :: IO () -> (EncryptionLevel -> Plain -> Plain) -> (Parameters -> Parameters) -> ([ExtensionRaw] -> [ExtensionRaw]) -> ([(EncryptionLevel, CryptoData)] -> ([(EncryptionLevel, CryptoData)], Bool)) -> (Stream -> ApplicationProtocolError -> IO ()) -> IO () -> (ConnectionInfo -> IO ()) -> Hooks [onCloseCompleted] :: Hooks -> IO () [onPlainCreated] :: Hooks -> EncryptionLevel -> Plain -> Plain [onTransportParametersCreated] :: Hooks -> Parameters -> Parameters [onTLSExtensionCreated] :: Hooks -> [ExtensionRaw] -> [ExtensionRaw] [onTLSHandshakeCreated] :: Hooks -> [(EncryptionLevel, CryptoData)] -> ([(EncryptionLevel, CryptoData)], Bool) [onResetStreamReceived] :: Hooks -> Stream -> ApplicationProtocolError -> IO () [onServerReady] :: Hooks -> IO () [onConnectionEstablished] :: Hooks -> ConnectionInfo -> IO () -- | Default hooks. defaultHooks :: Hooks -- | Client configuration. data ClientConfig ClientConfig :: Version -> [Version] -> [Cipher] -> [Group] -> Parameters -> (String -> IO ()) -> Maybe FilePath -> Credentials -> Hooks -> ClientHooks -> Bool -> HostName -> ServiceName -> (Version -> IO (Maybe [ByteString])) -> Bool -> ResumptionInfo -> Maybe Int -> Bool -> ClientConfig -- | The version to start with. [ccVersion] :: ClientConfig -> Version -- | Compatible versions with ccVersion in the preferred order. [ccVersions] :: ClientConfig -> [Version] -- | Cipher candidates defined in TLS 1.3. [ccCiphers] :: ClientConfig -> [Cipher] -- | Key exchange group candidates defined in TLS 1.3. [ccGroups] :: ClientConfig -> [Group] [ccParameters] :: ClientConfig -> Parameters [ccKeyLog] :: ClientConfig -> String -> IO () [ccQLog] :: ClientConfig -> Maybe FilePath -- | TLS credentials. [ccCredentials] :: ClientConfig -> Credentials [ccHooks] :: ClientConfig -> Hooks [ccTlsHooks] :: ClientConfig -> ClientHooks -- | Use 0-RTT on the 2nd connection if possible. client original [ccUse0RTT] :: ClientConfig -> Bool -- | Used to create a socket and SNI for TLS. [ccServerName] :: ClientConfig -> HostName -- | Used to create a socket. [ccPortName] :: ClientConfig -> ServiceName -- | An ALPN provider. [ccALPN] :: ClientConfig -> Version -> IO (Maybe [ByteString]) -- | Authenticating a server based on its certificate. [ccValidate] :: ClientConfig -> Bool -- | Use resumption on the 2nd connection if possible. [ccResumption] :: ClientConfig -> ResumptionInfo -- | QUIC packet size (UDP payload size) [ccPacketSize] :: ClientConfig -> Maybe Int [ccDebugLog] :: ClientConfig -> Bool -- | The default value for client configuration. defaultClientConfig :: ClientConfig -- | Server configuration. data ServerConfig ServerConfig :: [Version] -> [Cipher] -> [Group] -> Parameters -> (String -> IO ()) -> Maybe FilePath -> Credentials -> Hooks -> ServerHooks -> Bool -> [(IP, PortNumber)] -> Maybe (Version -> [ByteString] -> IO ByteString) -> Bool -> SessionManager -> Maybe FilePath -> Int -> ServerConfig -- | Fully-Deployed Versions in the preferred order. [scVersions] :: ServerConfig -> [Version] -- | Cipher candidates defined in TLS 1.3. [scCiphers] :: ServerConfig -> [Cipher] -- | Key exchange group candidates defined in TLS 1.3. [scGroups] :: ServerConfig -> [Group] [scParameters] :: ServerConfig -> Parameters [scKeyLog] :: ServerConfig -> String -> IO () [scQLog] :: ServerConfig -> Maybe FilePath -- | Server certificate information. [scCredentials] :: ServerConfig -> Credentials [scHooks] :: ServerConfig -> Hooks [scTlsHooks] :: ServerConfig -> ServerHooks -- | Use 0-RTT on the 2nd connection if possible. server original [scUse0RTT] :: ServerConfig -> Bool -- | Server addresses assigned to used network interfaces. [scAddresses] :: ServerConfig -> [(IP, PortNumber)] -- | ALPN handler. [scALPN] :: ServerConfig -> Maybe (Version -> [ByteString] -> IO ByteString) -- | Requiring QUIC retry. [scRequireRetry] :: ServerConfig -> Bool -- | A session manager of TLS 1.3. [scSessionManager] :: ServerConfig -> SessionManager [scDebugLog] :: ServerConfig -> Maybe FilePath -- | A lifetime (in seconds) for TLS session ticket and QUIC token. [scTicketLifetime] :: ServerConfig -> Int -- | The default value for server configuration. defaultServerConfig :: ServerConfig nextPacketNumber :: Connection -> IO PacketNumber setPeerPacketNumber :: Connection -> PacketNumber -> IO () getPeerPacketNumber :: Connection -> IO PacketNumber setEncryptionLevel :: Connection -> EncryptionLevel -> IO () waitEncryptionLevel :: Connection -> EncryptionLevel -> IO () putOffCrypto :: Connection -> EncryptionLevel -> ReceivedPacket -> IO () getCipher :: Connection -> EncryptionLevel -> IO Cipher setCipher :: Connection -> EncryptionLevel -> Cipher -> IO () getTLSMode :: Connection -> IO HandshakeMode13 getApplicationProtocol :: Connection -> IO (Maybe NegotiatedProtocol) setNegotiated :: Connection -> HandshakeMode13 -> Maybe NegotiatedProtocol -> ApplicationSecretInfo -> IO () dropSecrets :: Connection -> EncryptionLevel -> IO () initializeCoder :: Connection -> EncryptionLevel -> TrafficSecrets a -> IO () initializeCoder1RTT :: Connection -> TrafficSecrets ApplicationSecret -> IO () updateCoder1RTT :: Connection -> Bool -> IO () getCoder :: Connection -> EncryptionLevel -> Bool -> IO Coder getProtector :: Connection -> EncryptionLevel -> IO Protector getCurrentKeyPhase :: Connection -> IO (Bool, PacketNumber) setCurrentKeyPhase :: Connection -> Bool -> PacketNumber -> IO () getMyCID :: Connection -> IO CID getMyCIDs :: Connection -> IO [CID] getPeerCID :: Connection -> IO CID isMyCID :: Connection -> CID -> IO Bool myCIDsInclude :: Connection -> CID -> IO (Maybe Int) shouldUpdateMyCID :: Connection -> Int -> IO Bool shouldUpdatePeerCID :: Connection -> IO Bool -- | Reseting to Initial CID in the client side. resetPeerCID :: Connection -> CID -> IO () -- | Sending NewConnectionID getNewMyCID :: Connection -> IO CIDInfo getMyCIDSeqNum :: Connection -> IO Int -- | Peer starts using a new CID. setMyCID :: Connection -> CID -> IO () -- | Receiving NewConnectionID setPeerCIDAndRetireCIDs :: Connection -> Int -> IO [Int] -- | After sending RetireConnectionID retirePeerCID :: Connection -> Int -> IO () -- | Receiving RetireConnectionID retireMyCID :: Connection -> Int -> IO (Maybe CIDInfo) -- | Receiving NewConnectionID addPeerCID :: Connection -> CIDInfo -> IO Bool -- | Only for the internal "migration" API waitPeerCID :: Connection -> IO CIDInfo -- | Automatic CID update choosePeerCIDForPrivacy :: Connection -> IO () setPeerStatelessResetToken :: Connection -> StatelessResetToken -> IO () isStatelessRestTokenValid :: Connection -> CID -> StatelessResetToken -> IO Bool setMigrationStarted :: Connection -> IO () isPathValidating :: Connection -> IO Bool checkResponse :: Connection -> PathData -> IO () validatePath :: Connection -> Maybe CIDInfo -> IO () setVersionInfo :: Connection -> VersionInfo -> IO () getVersionInfo :: Connection -> IO VersionInfo setVersion :: Connection -> Version -> IO () getVersion :: Connection -> IO Version getOriginalVersion :: Connection -> Version getSocket :: Connection -> IO Socket setSocket :: Connection -> Socket -> IO Socket clearSocket :: Connection -> IO Socket getPeerInfo :: Connection -> IO PeerInfo setPeerInfo :: Connection -> PeerInfo -> IO () getPeerAuthCIDs :: Connection -> IO AuthCIDs setPeerAuthCIDs :: Connection -> (AuthCIDs -> AuthCIDs) -> IO () getClientDstCID :: Connection -> IO CID getMyParameters :: Connection -> Parameters getPeerParameters :: Connection -> IO Parameters setPeerParameters :: Connection -> Parameters -> IO () delayedAck :: Connection -> IO () resetDealyedAck :: Connection -> IO () setMaxPacketSize :: Connection -> Int -> IO () addReader :: Connection -> ThreadId -> IO () killReaders :: Connection -> IO () addResource :: Connection -> IO () -> IO () freeResources :: Connection -> IO () readMinIdleTimeout :: Connection -> IO Microseconds setMinIdleTimeout :: Connection -> Microseconds -> IO () sendFrames :: Connection -> EncryptionLevel -> [Frame] -> IO () sendFramesLim :: Connection -> EncryptionLevel -> [Frame] -> IO () -- | Closing a connection with/without a transport error. Internal threads -- should use this. closeConnection :: TransportError -> ReasonPhrase -> IO () -- | Closing a connection with an application protocol error. abortConnection :: Connection -> ApplicationProtocolError -> ReasonPhrase -> IO () setConnection0RTTReady :: Connection -> IO () isConnection1RTTReady :: Connection -> IO Bool setConnection1RTTReady :: Connection -> IO () isConnectionEstablished :: Connector a => a -> IO Bool setConnectionEstablished :: Connection -> IO () -- | Waiting until 0-RTT data can be sent. wait0RTTReady :: Connection -> IO () -- | Waiting until 1-RTT data can be sent. wait1RTTReady :: Connection -> IO () -- | For clients, waiting until HANDSHAKE_DONE is received. For servers, -- waiting until a TLS stack reports that the handshake is complete. waitEstablished :: Connection -> IO () readConnectionFlowTx :: Connection -> STM TxFlow addTxData :: Connection -> Int -> STM () setTxMaxData :: Connection -> Int -> IO () getRxMaxData :: Connection -> IO Int updateFlowRx :: Connection -> Int -> IO (Maybe Int) checkRxMaxData :: Connection -> Int -> IO Bool addTxBytes :: Connection -> Int -> IO () getTxBytes :: Connection -> IO Int addRxBytes :: Connection -> Int -> IO () getRxBytes :: Connection -> IO Int setAddressValidated :: Connection -> IO () waitAntiAmplificationFree :: Connection -> Int -> IO () checkAntiAmplificationFree :: Connection -> Int -> IO Bool getMyStreamId :: Connection -> IO Int possibleMyStreams :: Connection -> IO Int waitMyNewStreamId :: Connection -> IO StreamId waitMyNewUniStreamId :: Connection -> IO StreamId setTxMaxStreams :: Connection -> Int -> IO () setTxUniMaxStreams :: Connection -> Int -> IO () checkRxMaxStreams :: Connection -> StreamId -> IO Bool updatePeerStreamId :: Connection -> StreamId -> IO () checkStreamIdRoom :: Connection -> Direction -> IO (Maybe Int) createStream :: Connection -> StreamId -> IO Stream findStream :: Connection -> StreamId -> IO (Maybe Stream) addStream :: Connection -> StreamId -> IO Stream delStream :: Connection -> Stream -> IO () initialRxMaxStreamData :: Connection -> StreamId -> Int setupCryptoStreams :: Connection -> IO () clearCryptoStream :: Connection -> EncryptionLevel -> IO () getCryptoStream :: Connection -> EncryptionLevel -> IO (Maybe Stream) takeInput :: Connection -> IO Input putInput :: Connection -> Input -> IO () takeCrypto :: Connection -> IO Crypto putCrypto :: Connection -> Crypto -> IO () takeOutputSTM :: Connection -> STM Output tryTakeOutput :: Connection -> IO (Maybe Output) tryPeekOutput :: Connection -> IO (Maybe Output) putOutput :: Connection -> Output -> IO () outputLimit :: Int putOutputLim :: Connection -> Output -> IO () takeOutput1STM :: Connection -> STM Output takeSendStreamQ :: Connection -> IO TxStreamData takeSendStreamQSTM :: Connection -> STM TxStreamData tryPeekSendStreamQ :: Connection -> IO (Maybe TxStreamData) putSendStreamQ :: Connection -> TxStreamData -> IO () readMigrationQ :: Connection -> IO ReceivedPacket writeMigrationQ :: Connection -> ReceivedPacket -> IO () setToken :: Connection -> Token -> IO () getToken :: Connection -> IO Token -- | Getting information about resumption. getResumptionInfo :: Connection -> IO ResumptionInfo setRetried :: Connection -> Bool -> IO () getRetried :: Connection -> IO Bool setIncompatibleVN :: Connection -> Bool -> IO () getIncompatibleVN :: Connection -> IO Bool setResumptionSession :: Connection -> SessionEstablish setNewToken :: Connection -> Token -> IO () setRegister :: Connection -> (CID -> Connection -> IO ()) -> (CID -> IO ()) -> IO () getRegister :: Connection -> IO (CID -> Connection -> IO ()) getUnregister :: Connection -> IO (CID -> IO ()) setTokenManager :: Connection -> TokenManager -> IO () getTokenManager :: Connection -> IO TokenManager setBaseThreadId :: Connection -> ThreadId -> IO () getBaseThreadId :: Connection -> IO ThreadId setCertificateChain :: Connection -> Maybe CertificateChain -> IO () getCertificateChain :: Connection -> IO (Maybe CertificateChain) timeout :: Microseconds -> String -> IO a -> IO (Maybe a) fire :: Connection -> Microseconds -> TimeoutCallback -> IO () cfire :: Connection -> Microseconds -> TimeoutCallback -> IO (IO ()) delay :: Microseconds -> IO () dummySecrets :: TrafficSecrets a data RoleInfo ClientInfo :: Token -> ResumptionInfo -> Bool -> RoleInfo [clientInitialToken] :: RoleInfo -> Token [resumptionInfo] :: RoleInfo -> ResumptionInfo [incompatibleVN] :: RoleInfo -> Bool ServerInfo :: ~TokenManager -> (CID -> Connection -> IO ()) -> (CID -> IO ()) -> Bool -> ~ThreadId -> Maybe CertificateChain -> RoleInfo [tokenManager] :: RoleInfo -> ~TokenManager [registerCID] :: RoleInfo -> CID -> Connection -> IO () [unregisterCID] :: RoleInfo -> CID -> IO () [askRetry] :: RoleInfo -> Bool [baseThreadId] :: RoleInfo -> ~ThreadId [certChain] :: RoleInfo -> Maybe CertificateChain defaultClientRoleInfo :: RoleInfo defaultServerRoleInfo :: RoleInfo data CIDDB CIDDB :: CIDInfo -> IntMap CIDInfo -> Map CID Int -> Int -> Bool -> CIDDB [usedCIDInfo] :: CIDDB -> CIDInfo [cidInfos] :: CIDDB -> IntMap CIDInfo [revInfos] :: CIDDB -> Map CID Int [nextSeqNum] :: CIDDB -> Int [triggeredByMe] :: CIDDB -> Bool newCIDDB :: CID -> CIDDB data MigrationState NonMigration :: MigrationState MigrationStarted :: MigrationState SendChallenge :: PathData -> MigrationState RecvResponse :: MigrationState data Coder Coder :: (Buffer -> PlainText -> AssDat -> PacketNumber -> IO Int) -> (Buffer -> CipherText -> AssDat -> PacketNumber -> IO Int) -> Maybe Supplement -> Coder [encrypt] :: Coder -> Buffer -> PlainText -> AssDat -> PacketNumber -> IO Int [decrypt] :: Coder -> Buffer -> CipherText -> AssDat -> PacketNumber -> IO Int [supplement] :: Coder -> Maybe Supplement initialCoder :: Coder data Coder1RTT Coder1RTT :: Coder -> TrafficSecrets ApplicationSecret -> Coder1RTT [coder1RTT] :: Coder1RTT -> Coder [secretN] :: Coder1RTT -> TrafficSecrets ApplicationSecret initialCoder1RTT :: Coder1RTT data Protector Protector :: (Buffer -> IO ()) -> IO Buffer -> (Sample -> Mask) -> Protector [setSample] :: Protector -> Buffer -> IO () [getMask] :: Protector -> IO Buffer [unprotect] :: Protector -> Sample -> Mask initialProtector :: Protector data Negotiated Negotiated :: HandshakeMode13 -> Maybe NegotiatedProtocol -> ApplicationSecretInfo -> Negotiated [tlsHandshakeMode] :: Negotiated -> HandshakeMode13 [applicationProtocol] :: Negotiated -> Maybe NegotiatedProtocol [applicationSecretInfo] :: Negotiated -> ApplicationSecretInfo initialNegotiated :: Negotiated newtype StreamIdBase StreamIdBase :: Int -> StreamIdBase [fromStreamIdBase] :: StreamIdBase -> Int data Concurrency Concurrency :: StreamId -> StreamIdBase -> Concurrency [currentStream] :: Concurrency -> StreamId [maxStreams] :: Concurrency -> StreamIdBase newConcurrency :: Role -> Direction -> Int -> Concurrency type Send = Buffer -> Int -> IO () type Recv = IO ReceivedPacket data PeerInfo PeerInfo :: SockAddr -> [Cmsg] -> PeerInfo -- | A quic connection to carry multiple streams. data Connection Connection :: ConnState -> DebugLogger -> QLogger -> Hooks -> ~Send -> ~Recv -> RecvQ -> IORef Socket -> IORef (IO ()) -> ThreadId -> Rate -> IORef RoleInfo -> IORef VersionInfo -> VersionInfo -> Parameters -> IORef CIDDB -> IORef Parameters -> TVar CIDDB -> IORef PeerInfo -> InputQ -> CryptoQ -> OutputQ -> OutputQLim -> MigrationQ -> Shared -> IORef Int -> IORef (IO ()) -> IORef PacketNumber -> IORef StreamTable -> TVar Concurrency -> TVar Concurrency -> IORef Concurrency -> IORef Concurrency -> TVar TxFlow -> IORef RxFlow -> TVar MigrationState -> IORef Microseconds -> TVar Int -> TVar Int -> TVar Bool -> Array EncryptionLevel (TVar [ReceivedPacket]) -> IOArray EncryptionLevel Cipher -> IOArray EncryptionLevel Coder -> IOArray Bool Coder1RTT -> IOArray EncryptionLevel Protector -> IORef (Bool, PacketNumber) -> IORef Negotiated -> IORef AuthCIDs -> IORef AuthCIDs -> IORef (IO ()) -> Buffer -> SizedBuffer -> Buffer -> LDCC -> Connection [connState] :: Connection -> ConnState -- | A logger for debugging. [connDebugLog] :: Connection -> DebugLogger [connQLog] :: Connection -> QLogger [connHooks] :: Connection -> Hooks [connSend] :: Connection -> ~Send [connRecv] :: Connection -> ~Recv [connRecvQ] :: Connection -> RecvQ [connSocket] :: Connection -> IORef Socket [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 [peerInfo] :: Connection -> IORef PeerInfo [inputQ] :: Connection -> InputQ [cryptoQ] :: Connection -> CryptoQ [outputQ] :: Connection -> OutputQ [outputQLim] :: Connection -> OutputQLim [migrationQ] :: Connection -> MigrationQ [shared] :: Connection -> Shared [delayedAckCount] :: Connection -> IORef Int [delayedAckCancel] :: Connection -> IORef (IO ()) [peerPacketNumber] :: Connection -> IORef PacketNumber [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 Int [bytesRx] :: Connection -> TVar Int [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, PacketNumber) [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 setDead :: Connection -> IO () makePendingQ :: IO (Array EncryptionLevel (TVar [ReceivedPacket])) newConnection :: Role -> Parameters -> VersionInfo -> AuthCIDs -> AuthCIDs -> DebugLogger -> QLogger -> Hooks -> IORef Socket -> IORef PeerInfo -> RecvQ -> Send -> Recv -> IO Connection defaultTrafficSecrets :: (ClientTrafficSecret a, ServerTrafficSecret a) clientConnection :: ClientConfig -> VersionInfo -> AuthCIDs -> AuthCIDs -> DebugLogger -> QLogger -> Hooks -> IORef Socket -> IORef PeerInfo -> RecvQ -> Send -> Recv -> IO Connection serverConnection :: ServerConfig -> VersionInfo -> AuthCIDs -> AuthCIDs -> DebugLogger -> QLogger -> Hooks -> IORef Socket -> IORef PeerInfo -> RecvQ -> Send -> Recv -> IO Connection newtype Input InpStream :: Stream -> Input data Crypto InpHandshake :: EncryptionLevel -> ByteString -> Crypto data Output OutControl :: EncryptionLevel -> [Frame] -> IO () -> Output OutHandshake :: [(EncryptionLevel, ByteString)] -> Output OutRetrans :: PlainPacket -> Output type InputQ = TQueue Input type CryptoQ = TQueue Crypto type OutputQ = TQueue Output type OutputQLim = TBQueue Output type MigrationQ = TQueue ReceivedPacket type SendStreamQ = TQueue TxStreamData data Shared Shared :: IORef Bool -> IORef Bool -> IORef Bool -> SendStreamQ -> Shared [sharedCloseSent] :: Shared -> IORef Bool [sharedCloseReceived] :: Shared -> IORef Bool [shared1RTTReady] :: Shared -> IORef Bool [sharedSendStreamQ] :: Shared -> SendStreamQ newShared :: IO Shared class Connector a getRole :: Connector a => a -> Role getEncryptionLevel :: Connector a => a -> IO EncryptionLevel getMaxPacketSize :: Connector a => a -> IO Int getConnectionState :: Connector a => a -> IO ConnectionState getPacketNumber :: Connector a => a -> IO PacketNumber getAlive :: Connector a => a -> IO Bool data ConnState ConnState :: Role -> TVar ConnectionState -> IORef PacketNumber -> TVar EncryptionLevel -> IORef Int -> IORef Bool -> ConnState [role] :: ConnState -> Role [connectionState] :: ConnState -> TVar ConnectionState [packetNumber] :: ConnState -> IORef PacketNumber [encryptionLevel] :: ConnState -> TVar EncryptionLevel [maxPacketSize] :: ConnState -> IORef Int [connectionAlive] :: ConnState -> IORef Bool newConnState :: Role -> IO ConnState data Role Client :: Role Server :: Role isClient :: Connector a => a -> Bool isServer :: Connector a => a -> Bool data ConnectionState Handshaking :: ConnectionState ReadyFor0RTT :: ConnectionState ReadyFor1RTT :: ConnectionState Established :: ConnectionState isConnectionEstablished :: Connector a => a -> IO Bool data FusionContext fusionNewContext :: IO FusionContext fusionSetup :: Cipher -> FusionContext -> Key -> IV -> IO () fusionEncrypt :: FusionContext -> Supplement -> Buffer -> PlainText -> AssDat -> PacketNumber -> IO Int fusionDecrypt :: FusionContext -> Buffer -> CipherText -> AssDat -> PacketNumber -> IO Int data Supplement fusionSetupSupplement :: Cipher -> Key -> IO Supplement fusionSetSample :: Supplement -> Buffer -> IO () fusionGetMask :: Supplement -> IO Buffer isFusionAvailable :: IO Bool niteEncrypt :: Cipher -> Key -> IV -> PlainText -> AssDat -> PacketNumber -> Maybe (CipherText, CipherText) niteEncrypt' :: Cipher -> Key -> Nonce -> PlainText -> AssDat -> Maybe (CipherText, CipherText) niteDecrypt :: Cipher -> Key -> IV -> CipherText -> AssDat -> PacketNumber -> Maybe PlainText niteDecrypt' :: Cipher -> Key -> Nonce -> CipherText -> AssDat -> Maybe PlainText protectionMask :: Cipher -> Key -> Sample -> Mask aes128gcmEncrypt :: Key -> Nonce -> PlainText -> AssDat -> Maybe (CipherText, CipherText) makeNonce :: IV -> ByteString -> Nonce makeNiteEncrypt :: Cipher -> Key -> IV -> NiteEncrypt makeNiteDecrypt :: Cipher -> Key -> IV -> NiteDecrypt makeNiteProtector :: Cipher -> Key -> IO (Buffer -> IO (), IO Buffer) type PlainText = ByteString type CipherText = ByteString newtype Key Key :: ByteString -> Key newtype IV IV :: ByteString -> IV -- | A type for conneciton ID. data CID newtype Secret Secret :: ByteString -> Secret newtype AssDat AssDat :: ByteString -> AssDat newtype Sample Sample :: ByteString -> Sample newtype Mask Mask :: ByteString -> Mask newtype Nonce Nonce :: ByteString -> Nonce type Salt = ByteString newtype Label Label :: ByteString -> Label -- | Cipher algorithm data () => Cipher data InitialSecret -- | Hold both client and server traffic secrets at the same step. type TrafficSecrets a = (ClientTrafficSecret a, ServerTrafficSecret a) -- | A client traffic secret, typed with a parameter indicating a step in -- the TLS key schedule. newtype () => ClientTrafficSecret a ClientTrafficSecret :: ByteString -> ClientTrafficSecret a -- | A server traffic secret, typed with a parameter indicating a step in -- the TLS key schedule. newtype () => ServerTrafficSecret a ServerTrafficSecret :: ByteString -> ServerTrafficSecret a defaultCipher :: Cipher initialSecrets :: Version -> CID -> TrafficSecrets InitialSecret clientInitialSecret :: Version -> CID -> ClientTrafficSecret InitialSecret serverInitialSecret :: Version -> CID -> ServerTrafficSecret InitialSecret aeadKey :: Version -> Cipher -> Secret -> Key initialVector :: Version -> Cipher -> Secret -> IV nextSecret :: Version -> Cipher -> Secret -> Secret headerProtectionKey :: Version -> Cipher -> Secret -> Key tagLength :: Cipher -> Int sampleLength :: Cipher -> Int bsXOR :: ByteString -> ByteString -> ByteString calculateIntegrityTag :: Version -> CID -> ByteString -> ByteString -- | Builders denote sequences of bytes. They are Monoids -- where mempty is the zero-length sequence and mappend is -- concatenation, which runs in O(1). data () => Builder -- | A type for debug logger. type DebugLogger = Builder -> IO () bhow :: Show a => a -> Builder stdoutLogger :: DebugLogger dirDebugLogger :: Maybe FilePath -> CID -> IO (DebugLogger, IO ()) -- | This is not used internally. encodeVersionNegotiationPacket :: VersionNegotiationPacket -> IO ByteString encodeRetryPacket :: RetryPacket -> IO ByteString encodePlainPacket :: Connection -> SizedBuffer -> PlainPacket -> Maybe Int -> IO (Int, Int) decodePacket :: ByteString -> Bool -> IO (PacketI, ByteString) decodePackets :: ByteString -> Bool -> IO [PacketI] decodeCryptPackets :: ByteString -> Bool -> IO [(CryptPacket, EncryptionLevel, Int)] decryptCrypt :: Connection -> Crypt -> EncryptionLevel -> IO (Maybe Plain) decodeStatelessResetToken :: ByteString -> Maybe StatelessResetToken encodeFrames :: [Frame] -> IO ByteString decodeFramesBuffer :: Buffer -> BufferSize -> IO (Maybe [Frame]) decodeFramesBS :: ByteString -> IO (Maybe [Frame]) countZero :: Ptr Word8 -> Ptr Word8 -> IO Int isLong :: Word8 -> Bool isShort :: Flags Protected -> Bool protectFlags :: Flags Raw -> Word8 -> Flags Protected unprotectFlags :: Flags Protected -> Word8 -> Flags Raw encodeLongHeaderFlags :: Version -> LongHeaderPacketType -> Flags Raw -> Flags Raw -> Bool -> IO (Flags Raw) encodeShortHeaderFlags :: Flags Raw -> Flags Raw -> Bool -> Bool -> IO (Flags Raw) decodeLongHeaderPacketType :: Version -> Flags Protected -> LongHeaderPacketType encodePktNumLength :: Int -> Flags Raw decodePktNumLength :: Flags Raw -> Int versionNegotiationPacketType :: IO (Flags Raw) retryPacketType :: Version -> IO (Flags Raw) data CryptoToken CryptoToken :: Version -> Word32 -> TimeMicrosecond -> Maybe (CID, CID, CID) -> CryptoToken [tokenQUICVersion] :: CryptoToken -> Version [tokenLifeTime] :: CryptoToken -> Word32 [tokenCreatedTime] :: CryptoToken -> TimeMicrosecond [tokenCIDs] :: CryptoToken -> Maybe (CID, CID, CID) isRetryToken :: CryptoToken -> Bool generateToken :: Version -> Int -> IO CryptoToken generateRetryToken :: Version -> Int -> CID -> CID -> CID -> IO CryptoToken encryptToken :: TokenManager -> CryptoToken -> IO Token decryptToken :: TokenManager -> Token -> IO (Maybe CryptoToken) -- | QUIC transport parameters. data Parameters Parameters :: Maybe CID -> Milliseconds -> Maybe StatelessResetToken -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Milliseconds -> Bool -> Maybe ByteString -> Int -> Maybe CID -> Maybe CID -> Maybe ByteString -> Bool -> Maybe VersionInfo -> Parameters [originalDestinationConnectionId] :: Parameters -> Maybe CID [maxIdleTimeout] :: Parameters -> Milliseconds [statelessResetToken] :: Parameters -> Maybe StatelessResetToken [maxUdpPayloadSize] :: Parameters -> Int [initialMaxData] :: Parameters -> Int [initialMaxStreamDataBidiLocal] :: Parameters -> Int [initialMaxStreamDataBidiRemote] :: Parameters -> Int [initialMaxStreamDataUni] :: Parameters -> Int [initialMaxStreamsBidi] :: Parameters -> Int [initialMaxStreamsUni] :: Parameters -> Int [ackDelayExponent] :: Parameters -> Int [maxAckDelay] :: Parameters -> Milliseconds [disableActiveMigration] :: Parameters -> Bool [preferredAddress] :: Parameters -> Maybe ByteString [activeConnectionIdLimit] :: Parameters -> Int [initialSourceConnectionId] :: Parameters -> Maybe CID [retrySourceConnectionId] :: Parameters -> Maybe CID [grease] :: Parameters -> Maybe ByteString [greaseQuicBit] :: Parameters -> Bool [versionInformation] :: Parameters -> Maybe VersionInfo -- | An example parameters obsoleted in the near future. -- --
--   >>> defaultParameters
--   Parameters {originalDestinationConnectionId = Nothing, maxIdleTimeout = 30000, statelessResetToken = Nothing, maxUdpPayloadSize = 2048, initialMaxData = 16777216, initialMaxStreamDataBidiLocal = 262144, initialMaxStreamDataBidiRemote = 262144, initialMaxStreamDataUni = 262144, initialMaxStreamsBidi = 64, initialMaxStreamsUni = 3, ackDelayExponent = 3, maxAckDelay = 25, disableActiveMigration = False, preferredAddress = Nothing, activeConnectionIdLimit = 5, initialSourceConnectionId = Nothing, retrySourceConnectionId = Nothing, grease = Nothing, greaseQuicBit = True, versionInformation = Nothing}
--   
defaultParameters :: Parameters -- | The default value for QUIC transport parameters. baseParameters :: Parameters encodeParameters :: Parameters -> ByteString decodeParameters :: ByteString -> Maybe Parameters data AuthCIDs AuthCIDs :: Maybe CID -> Maybe CID -> Maybe CID -> AuthCIDs [initSrcCID] :: AuthCIDs -> Maybe CID [origDstCID] :: AuthCIDs -> Maybe CID [retrySrcCID] :: AuthCIDs -> Maybe CID defaultAuthCIDs :: AuthCIDs setCIDsToParameters :: AuthCIDs -> Parameters -> Parameters getCIDsToParameters :: Parameters -> AuthCIDs type QLogger = QlogMsg -> IO () newQlogger :: TimeMicrosecond -> ByteString -> CID -> FastLogger -> IO QLogger class Qlog a qlog :: Qlog a => a -> LogStr class KeepQlog a keepQlog :: KeepQlog a => a -> QLogger data QlogMsg QRecvInitial :: QlogMsg QSentRetry :: QlogMsg QSent :: LogStr -> TimeMicrosecond -> QlogMsg QReceived :: LogStr -> TimeMicrosecond -> QlogMsg QDropped :: LogStr -> TimeMicrosecond -> QlogMsg QMetricsUpdated :: LogStr -> TimeMicrosecond -> QlogMsg QPacketLost :: LogStr -> TimeMicrosecond -> QlogMsg QCongestionStateUpdated :: LogStr -> TimeMicrosecond -> QlogMsg QLossTimerUpdated :: LogStr -> TimeMicrosecond -> QlogMsg QDebug :: LogStr -> TimeMicrosecond -> QlogMsg QParamsSet :: LogStr -> TimeMicrosecond -> QlogMsg QCIDUpdate :: LogStr -> TimeMicrosecond -> QlogMsg qlogReceived :: (KeepQlog q, Qlog a) => q -> a -> TimeMicrosecond -> IO () qlogDropped :: (KeepQlog q, Qlog a) => q -> a -> IO () qlogRecvInitial :: KeepQlog q => q -> IO () qlogSentRetry :: KeepQlog q => q -> IO () qlogParamsSet :: KeepQlog q => q -> (Parameters, String) -> IO () qlogDebug :: KeepQlog q => q -> Debug -> IO () qlogCIDUpdate :: KeepQlog q => q -> LR -> IO () newtype Debug Debug :: LogStr -> Debug data LR Local :: CID -> LR Remote :: CID -> LR packetType :: Header -> LogStr sw :: Show a => a -> LogStr -- | An abstract data type for streams. data Stream -- | Getting stream identifier. streamId :: Stream -> StreamId streamConnection :: Stream -> Connection newStream :: Connection -> Int -> Int -> StreamId -> IO Stream data TxStreamData TxStreamData :: Stream -> [StreamData] -> Length -> Fin -> TxStreamData data StreamState StreamState :: Offset -> Fin -> StreamState [streamOffset] :: StreamState -> Offset [streamFin] :: StreamState -> Fin data RecvStreamQ RecvStreamQ :: TQueue ByteString -> IORef (Maybe ByteString) -> IORef Bool -> RecvStreamQ [recvStreamQ] :: RecvStreamQ -> TQueue ByteString [pendingData] :: RecvStreamQ -> IORef (Maybe ByteString) [endOfStream] :: RecvStreamQ -> IORef Bool data RxStreamData RxStreamData :: StreamData -> Offset -> Length -> Fin -> RxStreamData [rxstrmData] :: RxStreamData -> StreamData [rxstrmOff] :: RxStreamData -> Offset [rxstrmLen] :: RxStreamData -> Length [rxstrmFin] :: RxStreamData -> Fin type Length = Int syncFinTx :: Stream -> IO () waitFinTx :: Stream -> IO () getTxStreamOffset :: Stream -> Int -> IO Offset isTxStreamClosed :: Stream -> IO Bool setTxStreamClosed :: Stream -> IO () getRxStreamOffset :: Stream -> Int -> IO Offset isRxStreamClosed :: Stream -> IO Bool setRxStreamClosed :: Stream -> IO () readStreamFlowTx :: Stream -> STM TxFlow addTxStreamData :: Stream -> Int -> STM () setTxMaxStreamData :: Stream -> Int -> IO () getRxMaxStreamData :: Stream -> IO Int updateStreamFlowRx :: Stream -> Int -> IO (Maybe Int) takeRecvStreamQwithSize :: Stream -> Int -> IO ByteString putRxStreamData :: Stream -> RxStreamData -> IO FlowCntl data FlowCntl OverLimit :: FlowCntl Duplicated :: FlowCntl Reassembled :: FlowCntl tryReassemble :: Stream -> RxStreamData -> (StreamData -> IO ()) -> IO () -> IO Bool data StreamTable emptyStreamTable :: StreamTable lookupStream :: StreamId -> StreamTable -> Maybe Stream insertStream :: StreamId -> Stream -> StreamTable -> StreamTable deleteStream :: StreamId -> StreamTable -> StreamTable insertCryptoStreams :: Connection -> StreamTable -> IO StreamTable deleteCryptoStream :: EncryptionLevel -> StreamTable -> StreamTable lookupCryptoStream :: EncryptionLevel -> StreamTable -> Maybe Stream clientHandshaker :: QUICCallbacks -> ClientConfig -> Version -> AuthCIDs -> SessionEstablish -> Bool -> IO () serverHandshaker :: QUICCallbacks -> ServerConfig -> Version -> IO Parameters -> IO () -- | All internal byte sequences. ByteString should be used for FFI -- related stuff. type Bytes = ShortByteString type Close = IO () data Direction Unidirectional :: Direction Bidirectional :: Direction data SizedBuffer SizedBuffer :: Buffer -> BufferSize -> SizedBuffer type PacketNumber = Int type Range = Int type Gap = Int data AckInfo AckInfo :: PacketNumber -> Range -> [(Gap, Range)] -> AckInfo ackInfo0 :: AckInfo -- |
--   >>> toAckInfo [9]
--   AckInfo 9 0 []
--   
--   >>> toAckInfo [9,8,7]
--   AckInfo 9 2 []
--   
--   >>> toAckInfo [8,7,3,2]
--   AckInfo 8 1 [(2,1)]
--   
--   >>> toAckInfo [9,8,7,5,4]
--   AckInfo 9 2 [(0,1)]
--   
toAckInfo :: [PacketNumber] -> AckInfo -- |
--   >>> fromAckInfo $ AckInfo 9 0 []
--   [9]
--   
--   >>> fromAckInfo $ AckInfo 9 2 []
--   [7,8,9]
--   
--   >>> fromAckInfo $ AckInfo 8 1 [(2,1)]
--   [2,3,7,8]
--   
--   >>> fromAckInfo $ AckInfo 9 2 [(0,1)]
--   [4,5,7,8,9]
--   
fromAckInfo :: AckInfo -> [PacketNumber] -- |
--   >>> fromAckInfoWithMin (AckInfo 9 0 []) 1
--   [9]
--   
--   >>> fromAckInfoWithMin (AckInfo 9 2 []) 8
--   [8,9]
--   
--   >>> fromAckInfoWithMin (AckInfo 8 1 [(2,1)]) 3
--   [3,7,8]
--   
--   >>> fromAckInfoWithMin (AckInfo 9 2 [(0,1)]) 8
--   [8,9]
--   
fromAckInfoWithMin :: AckInfo -> PacketNumber -> [PacketNumber] fromAckInfoToPred :: AckInfo -> PacketNumber -> Bool newtype PeerPacketNumbers PeerPacketNumbers :: IntSet -> PeerPacketNumbers emptyPeerPacketNumbers :: PeerPacketNumbers -- | A type for conneciton ID. newtype CID CID :: Bytes -> CID myCIDLength :: Int newCID :: IO CID -- | Converting a connection ID. fromCID :: CID -> ByteString toCID :: ByteString -> CID makeCID :: ShortByteString -> CID unpackCID :: CID -> (ShortByteString, Word8) newtype StatelessResetToken StatelessResetToken :: Bytes -> StatelessResetToken newStatelessResetToken :: IO StatelessResetToken newtype PathData PathData :: Bytes -> PathData newPathData :: IO PathData data CIDInfo CIDInfo :: Int -> CID -> StatelessResetToken -> CIDInfo [cidInfoSeq] :: CIDInfo -> Int [cidInfoCID] :: CIDInfo -> CID [cidInfoSRT] :: CIDInfo -> StatelessResetToken maximumUdpPayloadSize :: Int defaultQUICPacketSize :: Int defaultQUICPacketSizeForIPv4 :: Int defaultQUICPacketSizeForIPv6 :: Int maximumQUICHeaderSize :: Int idleTimeout :: Microseconds -- | Transport errors of QUIC. newtype TransportError TransportError :: Int -> TransportError pattern NoError :: TransportError pattern InternalError :: TransportError pattern ConnectionRefused :: TransportError pattern FlowControlError :: TransportError pattern StreamLimitError :: TransportError pattern StreamStateError :: TransportError pattern FinalSizeError :: TransportError pattern FrameEncodingError :: TransportError pattern TransportParameterError :: TransportError pattern ConnectionIdLimitError :: TransportError pattern ProtocolViolation :: TransportError pattern InvalidToken :: TransportError pattern ApplicationError :: TransportError pattern CryptoBufferExceeded :: TransportError pattern KeyUpdateError :: TransportError pattern AeadLimitReached :: TransportError pattern NoViablePath :: TransportError pattern VersionNegotiationError :: TransportError -- | Converting a TLS alert to a corresponding transport error. cryptoError :: AlertDescription -> TransportError -- | Application protocol errors of QUIC. newtype ApplicationProtocolError ApplicationProtocolError :: Int -> ApplicationProtocolError -- | User level exceptions for QUIC. data QUICException ConnectionIsClosed :: QUICException TransportErrorIsReceived :: TransportError -> ReasonPhrase -> QUICException TransportErrorIsSent :: TransportError -> ReasonPhrase -> QUICException ApplicationProtocolErrorIsReceived :: ApplicationProtocolError -> ReasonPhrase -> QUICException ApplicationProtocolErrorIsSent :: ApplicationProtocolError -> ReasonPhrase -> QUICException ConnectionIsTimeout :: String -> QUICException ConnectionIsReset :: QUICException StreamIsClosed :: QUICException HandshakeFailed :: AlertDescription -> QUICException VersionIsUnknown :: Word32 -> QUICException NoVersionIsSpecified :: QUICException VersionNegotiationFailed :: QUICException BadThingHappen :: SomeException -> QUICException data InternalControl MustNotReached :: InternalControl ExitConnection :: InternalControl WrongTransportParameter :: InternalControl WrongVersionInformation :: InternalControl BreakForever :: InternalControl newtype NextVersion NextVersion :: VersionInfo -> NextVersion data Abort Abort :: ApplicationProtocolError -> ReasonPhrase -> Abort VerNego :: VersionInfo -> Abort type FrameType = Int data Direction Unidirectional :: Direction Bidirectional :: Direction type ReasonPhrase = ShortByteString type SeqNum = Int data Frame Padding :: Int -> Frame Ping :: Frame Ack :: AckInfo -> Delay -> Frame ResetStream :: StreamId -> ApplicationProtocolError -> Int -> Frame StopSending :: StreamId -> ApplicationProtocolError -> Frame CryptoF :: Offset -> CryptoData -> Frame NewToken :: Token -> Frame StreamF :: StreamId -> Offset -> [StreamData] -> Fin -> Frame MaxData :: Int -> Frame MaxStreamData :: StreamId -> Int -> Frame MaxStreams :: Direction -> Int -> Frame DataBlocked :: Int -> Frame StreamDataBlocked :: StreamId -> Int -> Frame StreamsBlocked :: Direction -> Int -> Frame NewConnectionID :: CIDInfo -> SeqNum -> Frame RetireConnectionID :: SeqNum -> Frame PathChallenge :: PathData -> Frame PathResponse :: PathData -> Frame ConnectionClose :: TransportError -> FrameType -> ReasonPhrase -> Frame ConnectionCloseApp :: ApplicationProtocolError -> ReasonPhrase -> Frame HandshakeDone :: Frame UnknownFrame :: Int -> Frame -- | Stream identifier. This should be 62-bit interger. On 32-bit machines, -- the total number of stream identifiers is limited. type StreamId = Int -- | Checking if a stream is client-initiated bidirectional. isClientInitiatedBidirectional :: StreamId -> Bool -- | Checking if a stream is server-initiated bidirectional. isServerInitiatedBidirectional :: StreamId -> Bool -- | Checking if a stream is client-initiated unidirectional. isClientInitiatedUnidirectional :: StreamId -> Bool -- | Checking if a stream is server-initiated unidirectional. isServerInitiatedUnidirectional :: StreamId -> Bool isClientInitiated :: StreamId -> Bool isServerInitiated :: StreamId -> Bool isBidirectional :: StreamId -> Bool isUnidirectional :: StreamId -> Bool type Delay = Milliseconds type Fin = Bool type CryptoData = ByteString type StreamData = ByteString type Token = ByteString emptyToken :: Token ackEliciting :: Frame -> Bool pathValidating :: Frame -> Bool inFlight :: Frame -> Bool rateControled :: Frame -> Bool -- |
--   >>> enc16 $ encodeInt 151288809941952652
--   "c2197c5eff14e88c"
--   
--   >>> enc16 $ encodeInt 494878333
--   "9d7f3e7d"
--   
--   >>> enc16 $ encodeInt 15293
--   "7bbd"
--   
--   >>> enc16 $ encodeInt 37
--   "25"
--   
encodeInt :: Int64 -> ByteString encodeInt8 :: Int64 -> ByteString encodeInt' :: WriteBuffer -> Int64 -> IO () encodeInt'2 :: WriteBuffer -> Int64 -> IO () encodeInt'4 :: WriteBuffer -> Int64 -> IO () -- |
--   >>> decodeInt (dec16 "c2197c5eff14e88c")
--   151288809941952652
--   
--   >>> decodeInt (dec16 "9d7f3e7d")
--   494878333
--   
--   >>> decodeInt (dec16 "7bbd")
--   15293
--   
--   >>> decodeInt (dec16 "25")
--   37
--   
decodeInt :: ByteString -> Int64 decodeInt' :: ReadBuffer -> IO Int64 -- | QUIC version. newtype Version Version :: Word32 -> Version pattern Negotiation :: Version pattern Version1 :: Version pattern Version2 :: Version pattern Draft29 :: Version pattern GreasingVersion :: Version pattern GreasingVersion2 :: Version isGreasingVersion :: Version -> Bool data VersionInfo VersionInfo :: Version -> [Version] -> VersionInfo [chosenVersion] :: VersionInfo -> Version [otherVersions] :: VersionInfo -> [Version] brokenVersionInfo :: VersionInfo extensionIDForTtransportParameter :: Version -> ExtensionID data PacketI PacketIV :: VersionNegotiationPacket -> PacketI PacketIR :: RetryPacket -> PacketI PacketIC :: CryptPacket -> EncryptionLevel -> Int -> PacketI PacketIB :: BrokenPacket -> Int -> PacketI data PacketO PacketOV :: VersionNegotiationPacket -> PacketO PacketOR :: RetryPacket -> PacketO PacketOP :: PlainPacket -> PacketO data VersionNegotiationPacket VersionNegotiationPacket :: CID -> CID -> [Version] -> VersionNegotiationPacket data RetryPacket RetryPacket :: Version -> CID -> CID -> Token -> Either CID (ByteString, ByteString) -> RetryPacket data BrokenPacket BrokenPacket :: BrokenPacket data Header Initial :: Version -> CID -> CID -> Token -> Header RTT0 :: Version -> CID -> CID -> Header Handshake :: Version -> CID -> CID -> Header Short :: CID -> Header headerMyCID :: Header -> CID headerPeerCID :: Header -> CID data PlainPacket PlainPacket :: Header -> Plain -> PlainPacket data CryptPacket CryptPacket :: Header -> Crypt -> CryptPacket data Plain Plain :: Flags Raw -> PacketNumber -> [Frame] -> Int -> Plain [plainFlags] :: Plain -> Flags Raw [plainPacketNumber] :: Plain -> PacketNumber [plainFrames] :: Plain -> [Frame] [plainMarks] :: Plain -> Int defaultPlainMarks :: Int setIllegalReservedBits :: Int -> Int setUnknownFrame :: Int -> Int setNoFrames :: Int -> Int setNoPaddings :: Int -> Int set4bytesPN :: Int -> Int isIllegalReservedBits :: Int -> Bool isUnknownFrame :: Int -> Bool isNoFrames :: Int -> Bool isNoPaddings :: Int -> Bool is4bytesPN :: Int -> Bool data Crypt Crypt :: Int -> ByteString -> Int -> Crypt [cryptPktNumOffset] :: Crypt -> Int [cryptPacket] :: Crypt -> ByteString [cryptMarks] :: Crypt -> Int isCryptDelayed :: Crypt -> Bool setCryptDelayed :: Crypt -> Crypt data StatelessReset StatelessReset :: StatelessReset data ReceivedPacket ReceivedPacket :: CryptPacket -> TimeMicrosecond -> Int -> EncryptionLevel -> ReceivedPacket [rpCryptPacket] :: ReceivedPacket -> CryptPacket [rpTimeRecevied] :: ReceivedPacket -> TimeMicrosecond [rpReceivedBytes] :: ReceivedPacket -> Int [rpEncryptionLevel] :: ReceivedPacket -> EncryptionLevel mkReceivedPacket :: CryptPacket -> TimeMicrosecond -> Int -> EncryptionLevel -> ReceivedPacket data LongHeaderPacketType InitialPacketType :: LongHeaderPacketType RTT0PacketType :: LongHeaderPacketType HandshakePacketType :: LongHeaderPacketType RetryPacketType :: LongHeaderPacketType data EncryptionLevel InitialLevel :: EncryptionLevel RTT0Level :: EncryptionLevel HandshakeLevel :: EncryptionLevel RTT1Level :: EncryptionLevel packetEncryptionLevel :: Header -> EncryptionLevel newtype Flags a Flags :: Word8 -> Flags a data Protected data Raw type EncodedPacketNumber = Word32 newtype RecvQ RecvQ :: TQueue ReceivedPacket -> RecvQ newRecvQ :: IO RecvQ readRecvQ :: RecvQ -> IO ReceivedPacket writeRecvQ :: RecvQ -> ReceivedPacket -> IO () prependRecvQ :: RecvQ -> ReceivedPacket -> STM () type SessionEstablish = SessionID -> SessionData -> IO (Maybe Ticket) -- | Information about resumption data ResumptionInfo ResumptionInfo :: Version -> Maybe (SessionID, SessionData) -> Token -> Bool -> ResumptionInfo [resumptionVersion] :: ResumptionInfo -> Version [resumptionSession] :: ResumptionInfo -> Maybe (SessionID, SessionData) [resumptionToken] :: ResumptionInfo -> Token [resumptionRetry] :: ResumptionInfo -> Bool defaultResumptionInfo :: ResumptionInfo -- | Is 0RTT possible? is0RTTPossible :: ResumptionInfo -> Bool -- | Is resumption possible? isResumptionPossible :: ResumptionInfo -> Bool get0RTTCipher :: ResumptionInfo -> Maybe CipherID newtype Milliseconds Milliseconds :: Int64 -> Milliseconds newtype Microseconds Microseconds :: Int -> Microseconds milliToMicro :: Milliseconds -> Microseconds microToMilli :: Microseconds -> Milliseconds type TimeMicrosecond = UnixTime timeMicrosecond0 :: UnixTime getTimeMicrosecond :: IO TimeMicrosecond getElapsedTimeMicrosecond :: TimeMicrosecond -> IO Microseconds elapsedTimeMicrosecond :: UnixTime -> UnixTime -> Microseconds getTimeoutInMicrosecond :: TimeMicrosecond -> IO Microseconds getPastTimeMicrosecond :: Microseconds -> IO TimeMicrosecond getFutureTimeMicrosecond :: Microseconds -> IO TimeMicrosecond addMicroseconds :: TimeMicrosecond -> Microseconds -> TimeMicrosecond fromRight :: b -> Either a b -> b dec16 :: ByteString -> ByteString enc16 :: ByteString -> ByteString dec16s :: ShortByteString -> ShortByteString enc16s :: ShortByteString -> ShortByteString shortToString :: ShortByteString -> String getRandomOneByte :: IO Word8 getRandomBytes :: Int -> IO ShortByteString totalLen :: [ByteString] -> Int sum' :: (Functor f, Foldable f) => f Int -> Int withByteString :: ByteString -> (Ptr Word8 -> IO a) -> IO a shortpack :: String -> ShortByteString ignore :: SomeException -> IO () checkWindowOpenSTM :: LDCC -> Int -> STM () takePingSTM :: LDCC -> STM EncryptionLevel speedup :: LDCC -> EncryptionLevel -> LogStr -> IO () resender :: LDCC -> IO () onPacketSent :: LDCC -> SentPacket -> IO () onPacketReceived :: LDCC -> EncryptionLevel -> PacketNumber -> IO () onAckReceived :: LDCC -> EncryptionLevel -> AckInfo -> Microseconds -> IO () onPacketNumberSpaceDiscarded :: LDCC -> EncryptionLevel -> IO () setInitialCongestionWindow :: LDCC -> Int -> IO () getPreviousRTT1PPNs :: LDCC -> IO PeerPacketNumbers setPreviousRTT1PPNs :: LDCC -> PeerPacketNumbers -> IO () getSpeedingUp :: LDCC -> IO Bool getPacketNumberSpaceDiscarded :: LDCC -> EncryptionLevel -> IO Bool getAndSetPacketNumberSpaceDiscarded :: LDCC -> EncryptionLevel -> IO Bool setMaxAckDaley :: LDCC -> Microseconds -> IO () getPeerPacketNumbers :: LDCC -> EncryptionLevel -> IO PeerPacketNumbers fromPeerPacketNumbers :: PeerPacketNumbers -> [PacketNumber] nullPeerPacketNumbers :: PeerPacketNumbers -> Bool findDuration :: Seq SentPacket -> PacketNumber -> Maybe UnixDiffTime getPTO :: LDCC -> IO Microseconds releaseByRetry :: LDCC -> IO (Seq PlainPacket) releaseOldest :: LDCC -> EncryptionLevel -> IO (Maybe SentPacket) beforeAntiAmp :: LDCC -> IO () ldccTimer :: LDCC -> IO () data SentPacket spPlainPacket :: SentPacket -> PlainPacket spTimeSent :: SentPacket -> TimeMicrosecond spSentBytes :: SentPacket -> Int spEncryptionLevel :: SentPacket -> EncryptionLevel spPacketNumber :: SentPacket -> PacketNumber spPeerPacketNumbers :: SentPacket -> PeerPacketNumbers spAckEliciting :: SentPacket -> Bool mkSentPacket :: PacketNumber -> EncryptionLevel -> PlainPacket -> PeerPacketNumbers -> Bool -> SentPacket fixSentPacket :: SentPacket -> Int -> Int -> SentPacket data LDCC newLDCC :: ConnState -> QLogger -> (PlainPacket -> IO ()) -> IO LDCC qlogSent :: (KeepQlog q, Qlog pkt) => q -> pkt -> TimeMicrosecond -> IO () -- | How to control a connection. data ConnectionControl ChangeServerCID :: ConnectionControl ChangeClientCID :: ConnectionControl NATRebinding :: ConnectionControl ActiveMigration :: ConnectionControl controlConnection :: Connection -> ConnectionControl -> IO Bool windowsThreadBlockHack :: IO a -> IO a serverSocket :: (IP, PortNumber) -> IO Socket clientSocket :: HostName -> ServiceName -> IO (Socket, SockAddr) natRebinding :: SockAddr -> IO Socket