From f2c309c92393bf5e10ec863e79fa32a110f80fa3 Mon Sep 17 00:00:00 2001 From: Mindy Date: Thu, 16 May 2019 17:23:38 -0400 Subject: [PATCH] packet.mli yay --- packet.mli | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 packet.mli diff --git a/packet.mli b/packet.mli new file mode 100644 index 0000000..2673546 --- /dev/null +++ b/packet.mli @@ -0,0 +1,35 @@ +type port = int + +type host = + [ `Client of Fw_utils.client_link | `Client_gateway | `Firewall_uplink | `NetVM | `External of Ipaddr.t ] + +type transport_header = [`TCP of Tcp.Tcp_packet.t + |`UDP of Udp_packet.t + |`ICMP of Icmpv4_packet.t] + +type ('src, 'dst) t = { + ipv4_header : Ipv4_packet.t; + transport_header : transport_header; + transport_payload : Cstruct.t; + src : 'src; + dst : 'dst; +} + +val pp_transport_header : Format.formatter -> transport_header -> unit + +val pp_host : Format.formatter -> host -> unit + +val to_mirage_nat_packet : ('a, 'b) t -> Nat_packet.t + +val of_mirage_nat_packet : src:'a -> dst:'b -> Nat_packet.t -> ('a, 'b) t option + +(* possible actions to take for a packet: *) +type action = [ + | `Accept (* Send to destination, unmodified. *) + | `NAT (* Rewrite source field to the firewall's IP, with a fresh source port. + Also, add translation rules for future traffic in both directions, + between these hosts on these ports, and corresponding ICMP error traffic. *) + | `NAT_to of host * port (* As for [`NAT], but also rewrite the packet's + destination fields so it will be sent to [host:port]. *) + | `Drop of string (* Drop packet for this reason. *) +]