hmssql
Safe HaskellNone
LanguageHaskell2010

Hmssql.Tds.Smp

Description

The Session Multiplex Protocol's packet header: what carries the TDS packets of several requests over one connection under MARS.

MC-SMP

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

Documentation

data SmpHeader Source #

Constructors

SmpHeader 

Fields

Instances

Instances details
Show SmpHeader Source # 
Instance details

Defined in Hmssql.Tds.Smp

Eq SmpHeader Source # 
Instance details

Defined in Hmssql.Tds.Smp

data SmpFlag Source #

What a packet is.

Constructors

SmpSyn

0x01: opens a session.

SmpAck

0x02: carries a new window, nothing else.

SmpFin

0x04: closes a session.

SmpData

0x08: carries one TDS packet.

Instances

Instances details
Show SmpFlag Source # 
Instance details

Defined in Hmssql.Tds.Smp

Eq SmpFlag Source # 
Instance details

Defined in Hmssql.Tds.Smp

Methods

(==) :: SmpFlag -> SmpFlag -> Bool #

(/=) :: SmpFlag -> SmpFlag -> Bool #

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.