{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
module Network.QUIC.Types.Packet where
import Codec.Serialise
import Data.Ix
import GHC.Generics
import Network.TLS.QUIC (ExtensionID (EID_QuicTransportParameters, ExtensionID))
import Network.UDP
import Text.Printf
import Network.QUIC.Imports
import Network.QUIC.Types.Ack
import Network.QUIC.Types.CID
import Network.QUIC.Types.Frame
import Network.QUIC.Types.Time
newtype Version = Version Word32 deriving (Version -> Version -> Bool
(Version -> Version -> Bool)
-> (Version -> Version -> Bool) -> Eq Version
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Version -> Version -> Bool
== :: Version -> Version -> Bool
$c/= :: Version -> Version -> Bool
/= :: Version -> Version -> Bool
Eq, Eq Version
Eq Version =>
(Version -> Version -> Ordering)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Version)
-> (Version -> Version -> Version)
-> Ord Version
Version -> Version -> Bool
Version -> Version -> Ordering
Version -> Version -> Version
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Version -> Version -> Ordering
compare :: Version -> Version -> Ordering
$c< :: Version -> Version -> Bool
< :: Version -> Version -> Bool
$c<= :: Version -> Version -> Bool
<= :: Version -> Version -> Bool
$c> :: Version -> Version -> Bool
> :: Version -> Version -> Bool
$c>= :: Version -> Version -> Bool
>= :: Version -> Version -> Bool
$cmax :: Version -> Version -> Version
max :: Version -> Version -> Version
$cmin :: Version -> Version -> Version
min :: Version -> Version -> Version
Ord, (forall x. Version -> Rep Version x)
-> (forall x. Rep Version x -> Version) -> Generic Version
forall x. Rep Version x -> Version
forall x. Version -> Rep Version x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Version -> Rep Version x
from :: forall x. Version -> Rep Version x
$cto :: forall x. Rep Version x -> Version
to :: forall x. Rep Version x -> Version
Generic)
instance Serialise Version
pattern Negotiation :: Version
pattern $mNegotiation :: forall {r}. Version -> ((# #) -> r) -> ((# #) -> r) -> r
$bNegotiation :: Version
Negotiation = Version 0
pattern Version1 :: Version
pattern $mVersion1 :: forall {r}. Version -> ((# #) -> r) -> ((# #) -> r) -> r
$bVersion1 :: Version
Version1 = Version 1
pattern Version2 :: Version
pattern $mVersion2 :: forall {r}. Version -> ((# #) -> r) -> ((# #) -> r) -> r
$bVersion2 :: Version
Version2 = Version 0x6b3343cf
pattern Draft29 :: Version
pattern $mDraft29 :: forall {r}. Version -> ((# #) -> r) -> ((# #) -> r) -> r
$bDraft29 :: Version
Draft29 = Version 0xff00001d
pattern GreasingVersion :: Version
pattern $mGreasingVersion :: forall {r}. Version -> ((# #) -> r) -> ((# #) -> r) -> r
$bGreasingVersion :: Version
GreasingVersion = Version 0x0a0a0a0a
pattern GreasingVersion2 :: Version
pattern $mGreasingVersion2 :: forall {r}. Version -> ((# #) -> r) -> ((# #) -> r) -> r
$bGreasingVersion2 :: Version
GreasingVersion2 = Version 0x1a2a3a4a
instance Show Version where
show :: Version -> String
show (Version Word32
0) = String
"Negotiation"
show (Version Word32
1) = String
"Version1"
show (Version Word32
0x6b3343cf) = String
"Version2"
show (Version Word32
0xff00001d) = String
"Draft29"
show ver :: Version
ver@(Version Word32
v)
| Version -> Bool
isGreasingVersion Version
ver = String
"Greasing 0x" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> Word32 -> String
forall r. PrintfType r => String -> r
printf String
"%08x" Word32
v
| Bool
otherwise = String
"Version 0x" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> Word32 -> String
forall r. PrintfType r => String -> r
printf String
"%08x" Word32
v
isGreasingVersion :: Version -> Bool
isGreasingVersion :: Version -> Bool
isGreasingVersion (Version Word32
v) = Word32
v Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
.&. Word32
0x0a0a0a0a Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== Word32
0x0a0a0a0a
data VersionInfo = VersionInfo
{ VersionInfo -> Version
chosenVersion :: Version
, VersionInfo -> [Version]
otherVersions :: [Version]
}
deriving (VersionInfo -> VersionInfo -> Bool
(VersionInfo -> VersionInfo -> Bool)
-> (VersionInfo -> VersionInfo -> Bool) -> Eq VersionInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VersionInfo -> VersionInfo -> Bool
== :: VersionInfo -> VersionInfo -> Bool
$c/= :: VersionInfo -> VersionInfo -> Bool
/= :: VersionInfo -> VersionInfo -> Bool
Eq, Int -> VersionInfo -> ShowS
[VersionInfo] -> ShowS
VersionInfo -> String
(Int -> VersionInfo -> ShowS)
-> (VersionInfo -> String)
-> ([VersionInfo] -> ShowS)
-> Show VersionInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VersionInfo -> ShowS
showsPrec :: Int -> VersionInfo -> ShowS
$cshow :: VersionInfo -> String
show :: VersionInfo -> String
$cshowList :: [VersionInfo] -> ShowS
showList :: [VersionInfo] -> ShowS
Show)
brokenVersionInfo :: VersionInfo
brokenVersionInfo :: VersionInfo
brokenVersionInfo = Version -> [Version] -> VersionInfo
VersionInfo Version
Negotiation []
extensionIDForTtransportParameter :: Version -> ExtensionID
extensionIDForTtransportParameter :: Version -> ExtensionID
extensionIDForTtransportParameter Version
Version1 = ExtensionID
EID_QuicTransportParameters
extensionIDForTtransportParameter Version
Version2 = ExtensionID
EID_QuicTransportParameters
extensionIDForTtransportParameter Version
_ = Word16 -> ExtensionID
ExtensionID Word16
0xffa5
data PacketI
= PacketIV VersionNegotiationPacket
| PacketIR RetryPacket
| PacketIC CryptPacket EncryptionLevel Int
| PacketIB BrokenPacket Int
deriving (PacketI -> PacketI -> Bool
(PacketI -> PacketI -> Bool)
-> (PacketI -> PacketI -> Bool) -> Eq PacketI
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PacketI -> PacketI -> Bool
== :: PacketI -> PacketI -> Bool
$c/= :: PacketI -> PacketI -> Bool
/= :: PacketI -> PacketI -> Bool
Eq, Int -> PacketI -> ShowS
[PacketI] -> ShowS
PacketI -> String
(Int -> PacketI -> ShowS)
-> (PacketI -> String) -> ([PacketI] -> ShowS) -> Show PacketI
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PacketI -> ShowS
showsPrec :: Int -> PacketI -> ShowS
$cshow :: PacketI -> String
show :: PacketI -> String
$cshowList :: [PacketI] -> ShowS
showList :: [PacketI] -> ShowS
Show)
data PacketO
= PacketOV VersionNegotiationPacket
| PacketOR RetryPacket
| PacketOP PlainPacket
deriving (PacketO -> PacketO -> Bool
(PacketO -> PacketO -> Bool)
-> (PacketO -> PacketO -> Bool) -> Eq PacketO
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PacketO -> PacketO -> Bool
== :: PacketO -> PacketO -> Bool
$c/= :: PacketO -> PacketO -> Bool
/= :: PacketO -> PacketO -> Bool
Eq, Int -> PacketO -> ShowS
[PacketO] -> ShowS
PacketO -> String
(Int -> PacketO -> ShowS)
-> (PacketO -> String) -> ([PacketO] -> ShowS) -> Show PacketO
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PacketO -> ShowS
showsPrec :: Int -> PacketO -> ShowS
$cshow :: PacketO -> String
show :: PacketO -> String
$cshowList :: [PacketO] -> ShowS
showList :: [PacketO] -> ShowS
Show)
data VersionNegotiationPacket = VersionNegotiationPacket CID CID [Version]
deriving (VersionNegotiationPacket -> VersionNegotiationPacket -> Bool
(VersionNegotiationPacket -> VersionNegotiationPacket -> Bool)
-> (VersionNegotiationPacket -> VersionNegotiationPacket -> Bool)
-> Eq VersionNegotiationPacket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VersionNegotiationPacket -> VersionNegotiationPacket -> Bool
== :: VersionNegotiationPacket -> VersionNegotiationPacket -> Bool
$c/= :: VersionNegotiationPacket -> VersionNegotiationPacket -> Bool
/= :: VersionNegotiationPacket -> VersionNegotiationPacket -> Bool
Eq, Int -> VersionNegotiationPacket -> ShowS
[VersionNegotiationPacket] -> ShowS
VersionNegotiationPacket -> String
(Int -> VersionNegotiationPacket -> ShowS)
-> (VersionNegotiationPacket -> String)
-> ([VersionNegotiationPacket] -> ShowS)
-> Show VersionNegotiationPacket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VersionNegotiationPacket -> ShowS
showsPrec :: Int -> VersionNegotiationPacket -> ShowS
$cshow :: VersionNegotiationPacket -> String
show :: VersionNegotiationPacket -> String
$cshowList :: [VersionNegotiationPacket] -> ShowS
showList :: [VersionNegotiationPacket] -> ShowS
Show)
data RetryPacket
= RetryPacket Version CID CID Token (Either CID (ByteString, ByteString))
deriving (RetryPacket -> RetryPacket -> Bool
(RetryPacket -> RetryPacket -> Bool)
-> (RetryPacket -> RetryPacket -> Bool) -> Eq RetryPacket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RetryPacket -> RetryPacket -> Bool
== :: RetryPacket -> RetryPacket -> Bool
$c/= :: RetryPacket -> RetryPacket -> Bool
/= :: RetryPacket -> RetryPacket -> Bool
Eq, Int -> RetryPacket -> ShowS
[RetryPacket] -> ShowS
RetryPacket -> String
(Int -> RetryPacket -> ShowS)
-> (RetryPacket -> String)
-> ([RetryPacket] -> ShowS)
-> Show RetryPacket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RetryPacket -> ShowS
showsPrec :: Int -> RetryPacket -> ShowS
$cshow :: RetryPacket -> String
show :: RetryPacket -> String
$cshowList :: [RetryPacket] -> ShowS
showList :: [RetryPacket] -> ShowS
Show)
data BrokenPacket = BrokenPacket deriving (BrokenPacket -> BrokenPacket -> Bool
(BrokenPacket -> BrokenPacket -> Bool)
-> (BrokenPacket -> BrokenPacket -> Bool) -> Eq BrokenPacket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BrokenPacket -> BrokenPacket -> Bool
== :: BrokenPacket -> BrokenPacket -> Bool
$c/= :: BrokenPacket -> BrokenPacket -> Bool
/= :: BrokenPacket -> BrokenPacket -> Bool
Eq, Int -> BrokenPacket -> ShowS
[BrokenPacket] -> ShowS
BrokenPacket -> String
(Int -> BrokenPacket -> ShowS)
-> (BrokenPacket -> String)
-> ([BrokenPacket] -> ShowS)
-> Show BrokenPacket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BrokenPacket -> ShowS
showsPrec :: Int -> BrokenPacket -> ShowS
$cshow :: BrokenPacket -> String
show :: BrokenPacket -> String
$cshowList :: [BrokenPacket] -> ShowS
showList :: [BrokenPacket] -> ShowS
Show)
data
= Initial Version CID CID Token
| RTT0 Version CID CID
| Handshake Version CID CID
| Short CID
deriving (Header -> Header -> Bool
(Header -> Header -> Bool)
-> (Header -> Header -> Bool) -> Eq Header
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Header -> Header -> Bool
== :: Header -> Header -> Bool
$c/= :: Header -> Header -> Bool
/= :: Header -> Header -> Bool
Eq, Int -> Header -> ShowS
[Header] -> ShowS
Header -> String
(Int -> Header -> ShowS)
-> (Header -> String) -> ([Header] -> ShowS) -> Show Header
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Header -> ShowS
showsPrec :: Int -> Header -> ShowS
$cshow :: Header -> String
show :: Header -> String
$cshowList :: [Header] -> ShowS
showList :: [Header] -> ShowS
Show)
headerMyCID :: Header -> CID
(Initial Version
_ CID
cid CID
_ Token
_) = CID
cid
headerMyCID (RTT0 Version
_ CID
cid CID
_) = CID
cid
headerMyCID (Handshake Version
_ CID
cid CID
_) = CID
cid
headerMyCID (Short CID
cid) = CID
cid
headerPeerCID :: Header -> CID
(Initial Version
_ CID
_ CID
cid Token
_) = CID
cid
headerPeerCID (RTT0 Version
_ CID
_ CID
cid) = CID
cid
headerPeerCID (Handshake Version
_ CID
_ CID
cid) = CID
cid
headerPeerCID Short{} = Bytes -> CID
CID Bytes
""
data PlainPacket = PlainPacket Header Plain deriving (PlainPacket -> PlainPacket -> Bool
(PlainPacket -> PlainPacket -> Bool)
-> (PlainPacket -> PlainPacket -> Bool) -> Eq PlainPacket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PlainPacket -> PlainPacket -> Bool
== :: PlainPacket -> PlainPacket -> Bool
$c/= :: PlainPacket -> PlainPacket -> Bool
/= :: PlainPacket -> PlainPacket -> Bool
Eq, Int -> PlainPacket -> ShowS
[PlainPacket] -> ShowS
PlainPacket -> String
(Int -> PlainPacket -> ShowS)
-> (PlainPacket -> String)
-> ([PlainPacket] -> ShowS)
-> Show PlainPacket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PlainPacket -> ShowS
showsPrec :: Int -> PlainPacket -> ShowS
$cshow :: PlainPacket -> String
show :: PlainPacket -> String
$cshowList :: [PlainPacket] -> ShowS
showList :: [PlainPacket] -> ShowS
Show)
data CryptPacket = CryptPacket Header Crypt deriving (CryptPacket -> CryptPacket -> Bool
(CryptPacket -> CryptPacket -> Bool)
-> (CryptPacket -> CryptPacket -> Bool) -> Eq CryptPacket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CryptPacket -> CryptPacket -> Bool
== :: CryptPacket -> CryptPacket -> Bool
$c/= :: CryptPacket -> CryptPacket -> Bool
/= :: CryptPacket -> CryptPacket -> Bool
Eq, Int -> CryptPacket -> ShowS
[CryptPacket] -> ShowS
CryptPacket -> String
(Int -> CryptPacket -> ShowS)
-> (CryptPacket -> String)
-> ([CryptPacket] -> ShowS)
-> Show CryptPacket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CryptPacket -> ShowS
showsPrec :: Int -> CryptPacket -> ShowS
$cshow :: CryptPacket -> String
show :: CryptPacket -> String
$cshowList :: [CryptPacket] -> ShowS
showList :: [CryptPacket] -> ShowS
Show)
data Plain = Plain
{ Plain -> Flags Raw
plainFlags :: Flags Raw
, Plain -> Int
plainPacketNumber :: PacketNumber
, Plain -> [Frame]
plainFrames :: [Frame]
, Plain -> Int
plainMarks :: Int
}
deriving (Plain -> Plain -> Bool
(Plain -> Plain -> Bool) -> (Plain -> Plain -> Bool) -> Eq Plain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Plain -> Plain -> Bool
== :: Plain -> Plain -> Bool
$c/= :: Plain -> Plain -> Bool
/= :: Plain -> Plain -> Bool
Eq, Int -> Plain -> ShowS
[Plain] -> ShowS
Plain -> String
(Int -> Plain -> ShowS)
-> (Plain -> String) -> ([Plain] -> ShowS) -> Show Plain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Plain -> ShowS
showsPrec :: Int -> Plain -> ShowS
$cshow :: Plain -> String
show :: Plain -> String
$cshowList :: [Plain] -> ShowS
showList :: [Plain] -> ShowS
Show)
defaultPlainMarks :: Int
defaultPlainMarks :: Int
defaultPlainMarks = Int
0
setIllegalReservedBits :: Int -> Int
setIllegalReservedBits :: Int -> Int
setIllegalReservedBits = (Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`setBit` Int
0)
setUnknownFrame :: Int -> Int
setUnknownFrame :: Int -> Int
setUnknownFrame = (Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`setBit` Int
1)
setNoFrames :: Int -> Int
setNoFrames :: Int -> Int
setNoFrames = (Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`setBit` Int
2)
setNoPaddings :: Int -> Int
setNoPaddings :: Int -> Int
setNoPaddings = (Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`setBit` Int
8)
set4bytesPN :: Int -> Int
set4bytesPN :: Int -> Int
set4bytesPN = (Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`setBit` Int
9)
isIllegalReservedBits :: Int -> Bool
isIllegalReservedBits :: Int -> Bool
isIllegalReservedBits = (Int -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
`testBit` Int
0)
isUnknownFrame :: Int -> Bool
isUnknownFrame :: Int -> Bool
isUnknownFrame = (Int -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
`testBit` Int
1)
isNoFrames :: Int -> Bool
isNoFrames :: Int -> Bool
isNoFrames = (Int -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
`testBit` Int
2)
isNoPaddings :: Int -> Bool
isNoPaddings :: Int -> Bool
isNoPaddings = (Int -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
`testBit` Int
8)
is4bytesPN :: Int -> Bool
is4bytesPN :: Int -> Bool
is4bytesPN = (Int -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
`testBit` Int
9)
data MigrationInfo = MigrationInfo ListenSocket ClientSockAddr CID
deriving (MigrationInfo -> MigrationInfo -> Bool
(MigrationInfo -> MigrationInfo -> Bool)
-> (MigrationInfo -> MigrationInfo -> Bool) -> Eq MigrationInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MigrationInfo -> MigrationInfo -> Bool
== :: MigrationInfo -> MigrationInfo -> Bool
$c/= :: MigrationInfo -> MigrationInfo -> Bool
/= :: MigrationInfo -> MigrationInfo -> Bool
Eq, Int -> MigrationInfo -> ShowS
[MigrationInfo] -> ShowS
MigrationInfo -> String
(Int -> MigrationInfo -> ShowS)
-> (MigrationInfo -> String)
-> ([MigrationInfo] -> ShowS)
-> Show MigrationInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MigrationInfo -> ShowS
showsPrec :: Int -> MigrationInfo -> ShowS
$cshow :: MigrationInfo -> String
show :: MigrationInfo -> String
$cshowList :: [MigrationInfo] -> ShowS
showList :: [MigrationInfo] -> ShowS
Show)
data Crypt = Crypt
{ Crypt -> Int
cryptPktNumOffset :: Int
, Crypt -> Token
cryptPacket :: ByteString
, Crypt -> Int
cryptMarks :: Int
, Crypt -> Maybe MigrationInfo
cryptMigraionInfo :: Maybe MigrationInfo
}
deriving (Crypt -> Crypt -> Bool
(Crypt -> Crypt -> Bool) -> (Crypt -> Crypt -> Bool) -> Eq Crypt
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Crypt -> Crypt -> Bool
== :: Crypt -> Crypt -> Bool
$c/= :: Crypt -> Crypt -> Bool
/= :: Crypt -> Crypt -> Bool
Eq, Int -> Crypt -> ShowS
[Crypt] -> ShowS
Crypt -> String
(Int -> Crypt -> ShowS)
-> (Crypt -> String) -> ([Crypt] -> ShowS) -> Show Crypt
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Crypt -> ShowS
showsPrec :: Int -> Crypt -> ShowS
$cshow :: Crypt -> String
show :: Crypt -> String
$cshowList :: [Crypt] -> ShowS
showList :: [Crypt] -> ShowS
Show)
isCryptDelayed :: Crypt -> Bool
isCryptDelayed :: Crypt -> Bool
isCryptDelayed Crypt
crypt = Crypt -> Int
cryptMarks Crypt
crypt Int -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
`testBit` Int
1
setCryptDelayed :: Crypt -> Crypt
setCryptDelayed :: Crypt -> Crypt
setCryptDelayed Crypt
crypt = Crypt
crypt{cryptMarks = cryptMarks crypt `setBit` 1}
data StatelessReset = StatelessReset deriving (StatelessReset -> StatelessReset -> Bool
(StatelessReset -> StatelessReset -> Bool)
-> (StatelessReset -> StatelessReset -> Bool) -> Eq StatelessReset
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StatelessReset -> StatelessReset -> Bool
== :: StatelessReset -> StatelessReset -> Bool
$c/= :: StatelessReset -> StatelessReset -> Bool
/= :: StatelessReset -> StatelessReset -> Bool
Eq, Int -> StatelessReset -> ShowS
[StatelessReset] -> ShowS
StatelessReset -> String
(Int -> StatelessReset -> ShowS)
-> (StatelessReset -> String)
-> ([StatelessReset] -> ShowS)
-> Show StatelessReset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StatelessReset -> ShowS
showsPrec :: Int -> StatelessReset -> ShowS
$cshow :: StatelessReset -> String
show :: StatelessReset -> String
$cshowList :: [StatelessReset] -> ShowS
showList :: [StatelessReset] -> ShowS
Show)
data ReceivedPacket = ReceivedPacket
{ ReceivedPacket -> CryptPacket
rpCryptPacket :: CryptPacket
, ReceivedPacket -> TimeMicrosecond
rpTimeRecevied :: TimeMicrosecond
, ReceivedPacket -> Int
rpReceivedBytes :: Int
, ReceivedPacket -> EncryptionLevel
rpEncryptionLevel :: EncryptionLevel
}
deriving (ReceivedPacket -> ReceivedPacket -> Bool
(ReceivedPacket -> ReceivedPacket -> Bool)
-> (ReceivedPacket -> ReceivedPacket -> Bool) -> Eq ReceivedPacket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReceivedPacket -> ReceivedPacket -> Bool
== :: ReceivedPacket -> ReceivedPacket -> Bool
$c/= :: ReceivedPacket -> ReceivedPacket -> Bool
/= :: ReceivedPacket -> ReceivedPacket -> Bool
Eq, Int -> ReceivedPacket -> ShowS
[ReceivedPacket] -> ShowS
ReceivedPacket -> String
(Int -> ReceivedPacket -> ShowS)
-> (ReceivedPacket -> String)
-> ([ReceivedPacket] -> ShowS)
-> Show ReceivedPacket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReceivedPacket -> ShowS
showsPrec :: Int -> ReceivedPacket -> ShowS
$cshow :: ReceivedPacket -> String
show :: ReceivedPacket -> String
$cshowList :: [ReceivedPacket] -> ShowS
showList :: [ReceivedPacket] -> ShowS
Show)
mkReceivedPacket
:: CryptPacket -> TimeMicrosecond -> Int -> EncryptionLevel -> ReceivedPacket
mkReceivedPacket :: CryptPacket
-> TimeMicrosecond -> Int -> EncryptionLevel -> ReceivedPacket
mkReceivedPacket CryptPacket
cpkt TimeMicrosecond
tim Int
bytes EncryptionLevel
lvl =
ReceivedPacket
{ rpCryptPacket :: CryptPacket
rpCryptPacket = CryptPacket
cpkt
, rpTimeRecevied :: TimeMicrosecond
rpTimeRecevied = TimeMicrosecond
tim
, rpReceivedBytes :: Int
rpReceivedBytes = Int
bytes
, rpEncryptionLevel :: EncryptionLevel
rpEncryptionLevel = EncryptionLevel
lvl
}
data
= InitialPacketType
| RTT0PacketType
| HandshakePacketType
| RetryPacketType
deriving (LongHeaderPacketType -> LongHeaderPacketType -> Bool
(LongHeaderPacketType -> LongHeaderPacketType -> Bool)
-> (LongHeaderPacketType -> LongHeaderPacketType -> Bool)
-> Eq LongHeaderPacketType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LongHeaderPacketType -> LongHeaderPacketType -> Bool
== :: LongHeaderPacketType -> LongHeaderPacketType -> Bool
$c/= :: LongHeaderPacketType -> LongHeaderPacketType -> Bool
/= :: LongHeaderPacketType -> LongHeaderPacketType -> Bool
Eq, Int -> LongHeaderPacketType -> ShowS
[LongHeaderPacketType] -> ShowS
LongHeaderPacketType -> String
(Int -> LongHeaderPacketType -> ShowS)
-> (LongHeaderPacketType -> String)
-> ([LongHeaderPacketType] -> ShowS)
-> Show LongHeaderPacketType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LongHeaderPacketType -> ShowS
showsPrec :: Int -> LongHeaderPacketType -> ShowS
$cshow :: LongHeaderPacketType -> String
show :: LongHeaderPacketType -> String
$cshowList :: [LongHeaderPacketType] -> ShowS
showList :: [LongHeaderPacketType] -> ShowS
Show)
data EncryptionLevel
= InitialLevel
| RTT0Level
| HandshakeLevel
| RTT1Level
deriving (EncryptionLevel -> EncryptionLevel -> Bool
(EncryptionLevel -> EncryptionLevel -> Bool)
-> (EncryptionLevel -> EncryptionLevel -> Bool)
-> Eq EncryptionLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EncryptionLevel -> EncryptionLevel -> Bool
== :: EncryptionLevel -> EncryptionLevel -> Bool
$c/= :: EncryptionLevel -> EncryptionLevel -> Bool
/= :: EncryptionLevel -> EncryptionLevel -> Bool
Eq, Eq EncryptionLevel
Eq EncryptionLevel =>
(EncryptionLevel -> EncryptionLevel -> Ordering)
-> (EncryptionLevel -> EncryptionLevel -> Bool)
-> (EncryptionLevel -> EncryptionLevel -> Bool)
-> (EncryptionLevel -> EncryptionLevel -> Bool)
-> (EncryptionLevel -> EncryptionLevel -> Bool)
-> (EncryptionLevel -> EncryptionLevel -> EncryptionLevel)
-> (EncryptionLevel -> EncryptionLevel -> EncryptionLevel)
-> Ord EncryptionLevel
EncryptionLevel -> EncryptionLevel -> Bool
EncryptionLevel -> EncryptionLevel -> Ordering
EncryptionLevel -> EncryptionLevel -> EncryptionLevel
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: EncryptionLevel -> EncryptionLevel -> Ordering
compare :: EncryptionLevel -> EncryptionLevel -> Ordering
$c< :: EncryptionLevel -> EncryptionLevel -> Bool
< :: EncryptionLevel -> EncryptionLevel -> Bool
$c<= :: EncryptionLevel -> EncryptionLevel -> Bool
<= :: EncryptionLevel -> EncryptionLevel -> Bool
$c> :: EncryptionLevel -> EncryptionLevel -> Bool
> :: EncryptionLevel -> EncryptionLevel -> Bool
$c>= :: EncryptionLevel -> EncryptionLevel -> Bool
>= :: EncryptionLevel -> EncryptionLevel -> Bool
$cmax :: EncryptionLevel -> EncryptionLevel -> EncryptionLevel
max :: EncryptionLevel -> EncryptionLevel -> EncryptionLevel
$cmin :: EncryptionLevel -> EncryptionLevel -> EncryptionLevel
min :: EncryptionLevel -> EncryptionLevel -> EncryptionLevel
Ord, Ord EncryptionLevel
Ord EncryptionLevel =>
((EncryptionLevel, EncryptionLevel) -> [EncryptionLevel])
-> ((EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Int)
-> ((EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Int)
-> ((EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Bool)
-> ((EncryptionLevel, EncryptionLevel) -> Int)
-> ((EncryptionLevel, EncryptionLevel) -> Int)
-> Ix EncryptionLevel
(EncryptionLevel, EncryptionLevel) -> Int
(EncryptionLevel, EncryptionLevel) -> [EncryptionLevel]
(EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Bool
(EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Int
forall a.
Ord a =>
((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
$crange :: (EncryptionLevel, EncryptionLevel) -> [EncryptionLevel]
range :: (EncryptionLevel, EncryptionLevel) -> [EncryptionLevel]
$cindex :: (EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Int
index :: (EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Int
$cunsafeIndex :: (EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Int
unsafeIndex :: (EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Int
$cinRange :: (EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Bool
inRange :: (EncryptionLevel, EncryptionLevel) -> EncryptionLevel -> Bool
$crangeSize :: (EncryptionLevel, EncryptionLevel) -> Int
rangeSize :: (EncryptionLevel, EncryptionLevel) -> Int
$cunsafeRangeSize :: (EncryptionLevel, EncryptionLevel) -> Int
unsafeRangeSize :: (EncryptionLevel, EncryptionLevel) -> Int
Ix, Int -> EncryptionLevel -> ShowS
[EncryptionLevel] -> ShowS
EncryptionLevel -> String
(Int -> EncryptionLevel -> ShowS)
-> (EncryptionLevel -> String)
-> ([EncryptionLevel] -> ShowS)
-> Show EncryptionLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EncryptionLevel -> ShowS
showsPrec :: Int -> EncryptionLevel -> ShowS
$cshow :: EncryptionLevel -> String
show :: EncryptionLevel -> String
$cshowList :: [EncryptionLevel] -> ShowS
showList :: [EncryptionLevel] -> ShowS
Show)
packetEncryptionLevel :: Header -> EncryptionLevel
packetEncryptionLevel :: Header -> EncryptionLevel
packetEncryptionLevel Initial{} = EncryptionLevel
InitialLevel
packetEncryptionLevel RTT0{} = EncryptionLevel
RTT0Level
packetEncryptionLevel Handshake{} = EncryptionLevel
HandshakeLevel
packetEncryptionLevel Short{} = EncryptionLevel
RTT1Level
newtype Flags a = Flags Word8 deriving (Flags a -> Flags a -> Bool
(Flags a -> Flags a -> Bool)
-> (Flags a -> Flags a -> Bool) -> Eq (Flags a)
forall a. Flags a -> Flags a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Flags a -> Flags a -> Bool
== :: Flags a -> Flags a -> Bool
$c/= :: forall a. Flags a -> Flags a -> Bool
/= :: Flags a -> Flags a -> Bool
Eq, Int -> Flags a -> ShowS
[Flags a] -> ShowS
Flags a -> String
(Int -> Flags a -> ShowS)
-> (Flags a -> String) -> ([Flags a] -> ShowS) -> Show (Flags a)
forall a. Int -> Flags a -> ShowS
forall a. [Flags a] -> ShowS
forall a. Flags a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Int -> Flags a -> ShowS
showsPrec :: Int -> Flags a -> ShowS
$cshow :: forall a. Flags a -> String
show :: Flags a -> String
$cshowList :: forall a. [Flags a] -> ShowS
showList :: [Flags a] -> ShowS
Show)
data Protected
data Raw
type EncodedPacketNumber = Word32