hans-2.4.0.0: IPv4 Network Stack

Safe HaskellNone
LanguageHaskell98

Hans.NetworkStack

Contents

Synopsis

Documentation

class HasEthernet stack where Source

startEthernetLayer :: HasEthernet stack => stack -> IO () Source

Start the ethernet layer in a network stack.

addDevice :: HasEthernet stack => stack -> Mac -> Tx -> Rx -> IO () Source

Add an ethernet device to the ethernet layer.

removeDevice :: HasEthernet stack => stack -> Mac -> IO () Source

Remove a device from the ethernet layer.

deviceUp :: HasEthernet stack => stack -> Mac -> IO () Source

Bring an ethernet device in the ethernet layer up.

deviceDown :: HasEthernet stack => stack -> Mac -> IO () Source

Bring an ethernet device in the ethernet layer down.

class HasArp stack where Source

Methods

arpHandle :: stack -> ArpHandle Source

Instances

startArpLayer :: (HasEthernet stack, HasArp stack) => stack -> IO () Source

Start the arp layer in a network stack.

class HasIcmp4 stack where Source

Methods

icmp4Handle :: stack -> Icmp4Handle Source

startIcmp4Layer :: (HasIcmp4 stack, HasIP4 stack) => stack -> IO () Source

Start the icmp4 layer in a network stack..

class HasIP4 stack where Source

Methods

ip4Handle :: stack -> IP4Handle Source

Instances

startIP4Layer :: (HasArp stack, HasEthernet stack, HasIP4 stack) => stack -> IO () Source

Start the IP4 layer in a network stack.

type Mtu = Int Source

addIP4Addr :: (HasArp stack, HasIP4 stack) => stack -> IP4Mask -> Mac -> Mtu -> IO () Source

Add an IP4 address to a network stack.

routeVia :: HasIP4 stack => stack -> IP4Mask -> IP4 -> IO () Source

Add a route for a network, via an address.

listenIP4Protocol :: HasIP4 stack => stack -> IP4Protocol -> Handler -> IO () Source

Register a handler for an IP4 protocol

ignoreIP4Protocol :: HasIP4 stack => stack -> IP4Protocol -> IO () Source

Register a handler for an IP4 protocol

class HasUdp stack where Source

Methods

udpHandle :: stack -> UdpHandle Source

Instances

startUdpLayer :: (HasIP4 stack, HasIcmp4 stack, HasUdp stack) => stack -> IO () Source

Start the UDP layer of a network stack.

addUdpHandler :: HasUdp stack => stack -> UdpPort -> Handler -> IO () Source

Add a handler for a UDP port.

removeUdpHandler :: HasUdp stack => stack -> UdpPort -> IO () Source

Remove a handler for a UDP port.

queueUdp :: HasUdp stack => stack -> IP4Header -> ByteString -> IO () Source

Inject a packet into the UDP layer.

sendUdp :: HasUdp stack => stack -> IP4 -> Maybe UdpPort -> UdpPort -> ByteString -> IO () Source

Send a UDP packet.

class HasIP4 stack => HasTcp stack where Source

Methods

tcpHandle :: stack -> TcpHandle Source

Instances

startTcpLayer :: HasTcp stack => stack -> IO () Source

Start the TCP layer of a network stack.

listen :: HasTcp stack => stack -> IP4 -> TcpPort -> IO Socket Source

Listen for incoming connections.

connect :: HasTcp stack => stack -> IP4 -> TcpPort -> Maybe TcpPort -> IO Socket Source

Make a remote connection.

class HasUdp stack => HasDns stack where Source

Methods

dnsHandle :: stack -> DnsHandle Source

Instances

startDnsLayer :: HasDns stack => stack -> IO () Source

addNameServer :: HasDns stack => stack -> IP4 -> IO () Source

removeNameServer :: HasDns stack => stack -> IP4 -> IO () Source

getHostByAddr :: HasDns stack => stack -> IP4 -> IO HostEntry Source

Re-exported Types

DNS

data HostEntry Source

Constructors

HostEntry 

Instances

Sockets

Socket Functions

sockRemoteHost :: Socket -> IP4 Source

The remote host of a socket.

sockRemotePort :: Socket -> TcpPort Source

The remote port of a socket.

sockLocalPort :: Socket -> TcpPort Source

The local port of a socket.

accept :: Socket -> IO Socket Source

Accept new incoming connections on a listening socket.

close :: Socket -> IO () Source

Close an open socket.

sendBytes :: Socket -> ByteString -> IO Int64 Source

Send bytes over a socket. The number of bytes delivered will be returned, with 0 representing the other side having closed the connection.

recvBytes :: Socket -> Int64 -> IO ByteString Source

Receive bytes from a socket. A null ByteString represents the other end closing the socket.

Socket Exceptions

data ConnectError Source

A connect call failed.

Constructors

ConnectionRefused