Safe Haskell | None |
---|---|
Language | Haskell98 |
- data NetworkStack = NetworkStack {
- nsArp :: ArpHandle
- nsEthernet :: EthernetHandle
- nsIp4 :: IP4Handle
- nsIcmp4 :: Icmp4Handle
- nsUdp :: UdpHandle
- nsTcp :: TcpHandle
- nsDns :: DnsHandle
- newNetworkStack :: IO NetworkStack
- class HasEthernet stack where
- ethernetHandle :: stack -> EthernetHandle
- startEthernetLayer :: HasEthernet stack => stack -> IO ()
- addDevice :: HasEthernet stack => stack -> Mac -> Tx -> Rx -> IO ()
- removeDevice :: HasEthernet stack => stack -> Mac -> IO ()
- deviceUp :: HasEthernet stack => stack -> Mac -> IO ()
- deviceDown :: HasEthernet stack => stack -> Mac -> IO ()
- class HasArp stack where
- startArpLayer :: (HasEthernet stack, HasArp stack) => stack -> IO ()
- class HasIcmp4 stack where
- icmp4Handle :: stack -> Icmp4Handle
- startIcmp4Layer :: (HasIcmp4 stack, HasIP4 stack) => stack -> IO ()
- class HasIP4 stack where
- startIP4Layer :: (HasArp stack, HasEthernet stack, HasIP4 stack) => stack -> IO ()
- type Mtu = Int
- addIP4Addr :: (HasArp stack, HasIP4 stack) => stack -> IP4Mask -> Mac -> Mtu -> IO ()
- routeVia :: HasIP4 stack => stack -> IP4Mask -> IP4 -> IO ()
- listenIP4Protocol :: HasIP4 stack => stack -> IP4Protocol -> Handler -> IO ()
- ignoreIP4Protocol :: HasIP4 stack => stack -> IP4Protocol -> IO ()
- class HasUdp stack where
- startUdpLayer :: (HasIP4 stack, HasIcmp4 stack, HasUdp stack) => stack -> IO ()
- addUdpHandler :: HasUdp stack => stack -> UdpPort -> Handler -> IO ()
- removeUdpHandler :: HasUdp stack => stack -> UdpPort -> IO ()
- queueUdp :: HasUdp stack => stack -> IP4Header -> ByteString -> IO ()
- sendUdp :: HasUdp stack => stack -> IP4 -> Maybe UdpPort -> UdpPort -> ByteString -> IO ()
- class HasIP4 stack => HasTcp stack where
- startTcpLayer :: HasTcp stack => stack -> IO ()
- listen :: HasTcp stack => stack -> IP4 -> TcpPort -> IO Socket
- connect :: HasTcp stack => stack -> IP4 -> TcpPort -> Maybe TcpPort -> IO Socket
- class HasUdp stack => HasDns stack where
- startDnsLayer :: HasDns stack => stack -> IO ()
- addNameServer :: HasDns stack => stack -> IP4 -> IO ()
- removeNameServer :: HasDns stack => stack -> IP4 -> IO ()
- getHostByName :: HasDns stack => stack -> HostName -> IO HostEntry
- getHostByAddr :: HasDns stack => stack -> IP4 -> IO HostEntry
- data UdpPort
- data TcpPort
- type HostName = String
- data HostEntry = HostEntry {
- hostName :: HostName
- hostAliases :: [HostName]
- hostAddresses :: [IP4]
- data Socket
- sockRemoteHost :: Socket -> IP4
- sockRemotePort :: Socket -> TcpPort
- sockLocalPort :: Socket -> TcpPort
- accept :: Socket -> IO Socket
- close :: Socket -> IO ()
- sendBytes :: Socket -> ByteString -> IO Int64
- recvBytes :: Socket -> Int64 -> IO ByteString
- data AcceptError = AcceptError
- data CloseError = CloseError
- data ConnectError = ConnectionRefused
- data ListenError = ListenError
Documentation
data NetworkStack Source
An example implementation of the whole network stack.
NetworkStack | |
|
class HasEthernet stack where Source
ethernetHandle :: stack -> EthernetHandle 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.
startArpLayer :: (HasEthernet stack, HasArp stack) => stack -> IO () Source
Start the arp layer in a network stack.
startIcmp4Layer :: (HasIcmp4 stack, HasIP4 stack) => stack -> IO () Source
Start the icmp4 layer in a network stack..
startIP4Layer :: (HasArp stack, HasEthernet stack, HasIP4 stack) => stack -> IO () Source
Start the IP4 layer in a network stack.
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
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.
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.
startDnsLayer :: HasDns stack => stack -> IO () Source
addNameServer :: HasDns stack => stack -> IP4 -> IO () Source
removeNameServer :: HasDns stack => stack -> IP4 -> IO () Source
Re-exported Types
DNS
HostEntry | |
|
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.
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.