nettle-openflow-0.2.0: OpenFlow protocol messages, binary formats, and servers.




This module provides Get values for parsing various IP packets and headers from ByteStrings into a byte-sequence-independent representation as Haskell datatypes.


These are incomplete. The headers may not contain all the information that the protocols specify. For example, the Haskell representation of an IP Header only includes source and destination addresses and IP protocol number, even though an IP packet has many more header fields. More seriously, an IP header may have an optional extra headers section after the destination address. We assume this is not present. If it is present, then the transport protocol header will not be directly after the destination address, but will be after these options. Therefore functions that assume this, such as the getExactMatch function below, will give incorrect results when applied to such IP packets.

The Haskell representations of the headers for the transport protocols are similarly incomplete. Again, the Get instances for the transport protocols may not parse through the end of the transport protocol header.


IP Packet

type IPPacket = IPHeader :*: (IPBody :*: HNil)Source

An IP packet consists of a header and a body.

data IPHeader Source

An IP Header includes various information about the packet, including the type of payload it contains. Warning: this definition does not include every header field included in an IP packet.




ipSrcAddress :: !IPAddress
ipDstAddress :: !IPAddress
ipProtocol :: !IPProtocol
headerLength :: !Int
totalLength :: !Int
dscp :: !DifferentiatedServicesCodePoint

differentiated services code point - 6 bit number

data IPBody Source

The body of an IP packet can be either a TCP, UDP, ICMP or other packet. Packets other than TCP, UDP, ICMP are represented as unparsed ByteString values.


foldIPBody :: (TCPHeader -> a) -> (UDPHeader -> a) -> (ICMPHeader -> a) -> (ByteString -> a) -> IPBody -> aSource