Module Packet.Pdu

module Pdu: sig .. end
Pack/Unpack the whole protocol stack that fits entirely within a packet.

Each raw packet can be seen either as a bitstring or as a pile of layers (for instance, DNS over UDP over IP over Ethernet). This Module will convert between these two representations, without loss of information. Typically you want to unpack then update, then pack back to bitstring.


type layer = 
| Raw of Bitstring.bitstring (*
the fallback when the actual protocol is not known
*)
| Dhcp of Dhcp.Pdu.t
| Eth of Eth.Pdu.t
| Arp of Arp.Pdu.t
| Ip of Ip.Pdu.t
| Ip6 of Ip6.Pdu.t
| Udp of Udp.Pdu.t
| Tcp of Tcp.Pdu.t
| Dns of Dns.Pdu.t
| Sll of Sll.Pdu.t
| Vlan of Vlan.Pdu.t
| Icmp of Icmp.Pdu.t
| Pcap of Pcap.Pdu.t (*
A Pdu.t is a list of Packet.Pdu.layers, with the outer layer first for a more natural presentation when printed.
*)
Each layer can be of any one of these known protocol.
type t = layer list 
val pack : layer list -> Pcap.Pdu.t
pack pdu converts the layer list back to a Pcap.Pdu.t
val unpack : Pcap.Pdu.t -> layer list
Converts a Pcap.pdu.t into a Packet.Pdu.t.