2015-12-30 09:52:24 +00:00
|
|
|
(* Copyright (C) 2015, Thomas Leonard <thomas.leonard@unikernel.com>
|
|
|
|
See the README file for details. *)
|
|
|
|
|
|
|
|
(** Routing packets to the right network interface. *)
|
|
|
|
|
2017-03-02 14:52:55 +00:00
|
|
|
open Fw_utils
|
2015-12-30 09:52:24 +00:00
|
|
|
|
2015-12-30 16:07:16 +00:00
|
|
|
type t = private {
|
|
|
|
client_eth : Client_eth.t;
|
2017-03-02 14:52:55 +00:00
|
|
|
nat : My_nat.t;
|
2016-01-01 11:32:57 +00:00
|
|
|
uplink : interface;
|
2015-12-30 16:07:16 +00:00
|
|
|
}
|
2015-12-30 09:52:24 +00:00
|
|
|
|
|
|
|
val create :
|
2015-12-30 13:48:13 +00:00
|
|
|
client_eth:Client_eth.t ->
|
2016-01-01 11:32:57 +00:00
|
|
|
uplink:interface ->
|
2017-03-02 14:52:55 +00:00
|
|
|
nat:My_nat.t ->
|
2015-12-30 09:52:24 +00:00
|
|
|
t
|
2020-04-29 15:58:01 +02:00
|
|
|
(** [create ~client_eth ~uplink ~nat] is a new routing table
|
2016-01-01 11:32:57 +00:00
|
|
|
that routes packets outside of [client_eth] via [uplink]. *)
|
2015-12-30 09:52:24 +00:00
|
|
|
|
2017-03-02 14:52:55 +00:00
|
|
|
val target : t -> Ipv4_packet.t -> interface option
|
|
|
|
(** [target t packet] is the interface to which [packet] should be routed. *)
|
2015-12-30 09:52:24 +00:00
|
|
|
|
2016-09-25 15:14:16 +01:00
|
|
|
val add_client : t -> client_link -> unit Lwt.t
|
|
|
|
(** [add_client t iface] adds a rule for routing packets addressed to [iface]. *)
|
2015-12-30 09:52:24 +00:00
|
|
|
|
|
|
|
val remove_client : t -> client_link -> unit
|
2015-12-30 13:48:13 +00:00
|
|
|
|
2015-12-30 16:07:16 +00:00
|
|
|
val classify : t -> Ipaddr.t -> Packet.host
|
2016-01-01 11:32:57 +00:00
|
|
|
val resolve : t -> Packet.host -> Ipaddr.t
|