hans-3.0.2: Network Stack

Safe HaskellNone
LanguageHaskell2010

Hans.Tcp.Tcb

Contents

Synopsis

Timers

resetRetransmit :: TcpTimers -> (TcpTimers, ()) Source #

Reset retransmit info.

retryRetransmit :: TcpTimers -> (TcpTimers, ()) Source #

Increment the retry count, and double the last retransmit timer.

stopRetransmit :: TcpTimers -> (TcpTimers, ()) Source #

Invalidate the retransmit timer.

updateTimers :: TcpTimers -> (TcpTimers, TcpTimers) Source #

Update all slow-tick timers. Return the old timers, for use with 'atomicModifyIORef\''.

calibrateRTO :: NominalDiffTime -> TcpTimers -> (TcpTimers, ()) Source #

Calibrate the RTO timer, given a round-trip measurement, as specified by RFC-6298.

TCB States

class GetState tcb where Source #

Minimal complete definition

getState

Methods

getState :: tcb -> IO State Source #

whenState :: (BaseM m IO, GetState tcb) => tcb -> State -> m () -> m () Source #

setState :: Tcb -> State -> IO () Source #

The Tcb type is the only one that supports changing state.

Sending

class CanSend sock where Source #

Minimal complete definition

getSendWindow

Methods

getSendWindow :: BaseM io IO => sock -> io (TcpSeqNum, TcpSeqNum) Source #

getSndNxt :: (BaseM io IO, CanSend sock) => sock -> io TcpSeqNum Source #

getSndWnd :: (BaseM io IO, CanSend sock) => sock -> io TcpSeqNum Source #

Receiving

class CanReceive sock where Source #

Minimal complete definition

getRecvWindow

Methods

getRecvWindow :: BaseM io IO => sock -> io (TcpSeqNum, TcpSeqNum) Source #

Retrieve the left and right edges of the receive window:

(RCV.NXT, RCV.NXT + RCV.WND)

getRcvNxt :: (BaseM io IO, CanReceive sock) => sock -> io TcpSeqNum Source #

getRcvWnd :: (BaseM io IO, CanReceive sock) => sock -> io Word16 Source #

getRcvRight :: (BaseM io IO, CanReceive sock) => sock -> io TcpSeqNum Source #

Listening TCBs

data ListenTcb Source #

Constructors

ListenTcb 

Fields

newListenTcb :: Addr -> TcpPort -> Int -> IO ListenTcb Source #

Create a new listening socket.

createChild Source #

Arguments

:: HasConfig cfg 
=> cfg 
-> TcpSeqNum 
-> ListenTcb 
-> RouteInfo Addr 
-> Addr 
-> TcpHeader 
-> (Tcb -> State -> IO ())

On Established

-> (Tcb -> State -> IO ())

On Closed

-> IO Tcb 

Create a child from a Syn request.

reserveSlot :: ListenTcb -> IO Bool Source #

Reserve a slot in the accept queue, returns True when the space has been reserved.

releaseSlot :: ListenTcb -> IO () Source #

Release a slot back to the accept queue.

acceptTcb :: ListenTcb -> IO Tcb Source #

Wait until a Tcb is available in the accept queue.

Active TCBs

data Tcb Source #

Constructors

Tcb 

Fields

newTcb Source #

Arguments

:: HasConfig state 
=> state 
-> Maybe ListenTcb 
-> TcpSeqNum

ISS

-> RouteInfo Addr 
-> TcpPort 
-> Addr 
-> TcpPort 
-> State 
-> TSClock 
-> (Tcb -> State -> IO ()) 
-> (Tcb -> State -> IO ()) 
-> IO Tcb 

signalDelayedAck :: Tcb -> IO () Source #

Record that a delayed ack should be sent.

setRcvNxt :: TcpSeqNum -> Tcb -> IO Bool Source #

Set the value of RCV.NXT. Returns True when the value has been set successfully, and False if the receive queue was not empty.

finalizeTcb :: Tcb -> IO () Source #

Cleanup the Tcb.

resetIdleTimer :: TcpTimers -> (TcpTimers, ()) Source #

Reset idle timer in the presence of packets, for use with 'atomicModifyIORef\''.

Active Config

data TcbConfig Source #

Constructors

TcbConfig 

Fields

usingTimestamps :: Tcb -> IO Bool Source #

True when the timestamp option should be included.

disableTimestamp :: Tcb -> IO () Source #

Disable the use of the timestamp option.

Windowing

queueBytes :: ByteString -> Tcb -> IO () Source #

Queue bytes in the receive buffer.

haveBytesAvail :: Tcb -> IO Bool Source #

Determine if there are bytes in the receive buffer that can be read.

receiveBytes :: Int -> Tcb -> IO ByteString Source #

Remove data from the receive buffer, and move the right-side of the receive window. Reading 0 bytes indicates that the remote side has closed the connection.

tryReceiveBytes :: Int -> Tcb -> IO (Maybe ByteString) Source #

Non-blocking version of receiveBytes. Reading 0 bytes indicates that the remote side has closed the connection.

TimeWait TCBs