| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hmssql.Tds.Smp
Description
The Session Multiplex Protocol's packet header: what carries the TDS packets of several requests over one connection under MARS.
Every SMP packet starts with 16 bytes: the identifier 0x53, the flags (exactly one of SYN, ACK, FIN and DATA), the session's identifier, the packet's length (header included), a sequence number and a window, all little-endian. A DATA packet's payload is one TDS packet; the others have none.
The sequence number of a DATA packet is one more than that of the session's previous DATA packet from the same sender, the first being 1; a SYN carries 0, and an ACK or FIN the sender's last DATA sequence number. The window is the highest sequence number the sender of the packet will accept from its peer on this session: it only ever grows, as the sender consumes what it received.
Synopsis
- data SmpHeader = SmpHeader {}
- data SmpFlag
- smpFlagWord :: SmpFlag -> Word8
- smpHeaderLength :: Int
- smpIdentifier :: Word8
- readSmpHeader :: ByteString -> SmpHeader
- pokeSmpHeader :: Ptr Word8 -> SmpFlag -> Word16 -> Int -> Word32 -> Word32 -> IO ()
- smpControlPacket :: SmpFlag -> Word16 -> Word32 -> Word32 -> ByteString
- smpDataPacket :: Word16 -> Word32 -> Word32 -> ByteString -> [ByteString]
- smpInitialWindow :: Word32
Documentation
Constructors
| SmpHeader | |
Instances
What a packet is.
smpFlagWord :: SmpFlag -> Word8 Source #
smpIdentifier :: Word8 Source #
The first byte of every SMP packet (SMID).
readSmpHeader :: ByteString -> SmpHeader Source #
The header at the start of a buffer of at least smpHeaderLength
bytes whose first byte is smpIdentifier (the caller checks both).
pokeSmpHeader :: Ptr Word8 -> SmpFlag -> Word16 -> Int -> Word32 -> Word32 -> IO () Source #
Write a header at the pointer.
smpControlPacket :: SmpFlag -> Word16 -> Word32 -> Word32 -> ByteString Source #
A packet that is its header alone: a SYN, an ACK or a FIN.
smpDataPacket :: Word16 -> Word32 -> Word32 -> ByteString -> [ByteString] Source #
A DATA packet around a complete TDS packet, as its pieces: the header,
then the packet. The header is separate because its sequence number and
window are only known under the send lock, long after the packet is complete,
and a ByteString must not be written to once it exists.
smpInitialWindow :: Word32 Source #
The window a session has before its peer has said anything (MC-SMP 3.1.3): how far a client may send after its SYN, which the server doesn't answer.