tftp-0.2: A library for building tftp servers

Safe HaskellNone

Network.TFTP.Protocol

Description

Transmission of data via TFTP. This implements the stop-and-wait style data transmission protocol.

Synopsis

Documentation

type XFerT m address a = StateT (XFerState address) m aSource

XFer monad parameterised over a (MessageIO) monad.

runTFTP :: MessageIO m address => XFerT m address result -> m resultSource

Execute a transfer action.

offerSingleFile :: MessageIO m address => Maybe Int -> String -> ByteString -> XFerT m address BoolSource

A simple server action that will wait for a RRQ for its file.

writeData :: MessageIO m address => ByteString -> XFerT m address BoolSource

A transfer action that sends a large chunk of data via TFTP DATA messages to a destination.

continueAfterACK :: MessageIO m address => StateT (XFerState address) m b -> StateT (XFerState address) m b -> StateT (XFerState address) m b -> StateT (XFerState address) m bSource

Receive the next message from the client, if the client anserws with the correct ack call success. If there was a timeout or the ack was for an invalid index call retry, if an error occured call 'error

maxRetries :: IntSource

The default number of re-transmits during writeData

ackTimeOut :: Maybe IntSource

The default time continueAfterACK waits for an ACK.

data XFerState address Source

Internal state record for a transfer

Constructors

XFerState 

Fields

xsBlockIndex :: Word16

The block index of an ongoing transfer

xsFrom :: Maybe address

Origin of the last message received

resetBlockIndex :: Monad m => XFerT m address ()Source

Reset the current block index for an ongoing transfer to 0

getBlockIndex :: Monad m => XFerT m address Word16Source

Read the current block index for an ongoing transfer

incBlockIndex :: Monad m => XFerT m address Word16Source

Increment the current block index for an ongoing transfer

getLastPeer :: Monad m => XFerT m address (Maybe address)Source

Return the origin(Address) of the message last received, or Nothing

setLastPeer :: MessageIO m address => Maybe address -> XFerT m address ()Source

Overwrite the origin(Address) of the message last received

replyData :: MessageIO m address => ByteString -> XFerT m address ()Source

Send a DATA packet to the origin(Address) of the message last received with the current block index

reply :: MessageIO m address => Message -> XFerT m address ()Source

Send any Message to the address to where the last message received from

send :: MessageIO m address => address -> Message -> XFerT m address ()Source

Send any Message to an Address

receive :: MessageIO m address => Maybe Int -> XFerT m address (Maybe Message)Source

receive a message and remeber the sender for getLastPeer

printInfo :: MessageIO m address => String -> XFerT m address ()Source

Log debug message

printWarn :: MessageIO m address => String -> XFerT m address ()Source

Log warning message

printErr :: MessageIO m address => String -> XFerT m address ()Source

Log error message

logWith :: MessageIO m address => (String -> String -> IO ()) -> String -> XFerT m address ()Source

Log message with custom priority