Module Router.Router

module Router: sig .. end
A router is a device with N IP/Eth devices and a routing table with rules on interface number, Ip addresses, proto, ports.

type port_range = int * int 
Inclusive port range
val port_in_range : 'a -> 'a * 'a -> bool
type route = {
   iface_num : int option; (*
Test on incoming iface
*)
   src_mask : Ip.Cidr.t option; (*
Test on source IP
*)
   dst_mask : Ip.Cidr.t option; (*
Test on dest IP
*)
   ip_proto : Ip.Proto.t option; (*
Test on IP protocol
*)
   src_port : port_range option; (*
Test on source port
*)
   dst_port : port_range option;
}
A route is a set of optional tests.

Test on dest port

val test_route : route ->
int ->
Ip.Addr.t option ->
Ip.Addr.t option -> Ip.Proto.t option -> int option -> int option -> bool
Test an incoming packet against a route.
type t = {
   trxs : Tools.trx array;
   route_tbl : (route * int) array;
}
A router is an array of trxs and a route table

The route table is an array of route to output interface indices.

val route : int -> t -> Bitstring.bitstring -> unit
val set_read : int -> t -> (Bitstring.bitstring -> unit) -> unit
Change the emitter of port N. Note that the emitter may also be preset in the trx array given to make.
val make : Tools.trx array -> (route * int) array -> t
Build a t routing through these Tools.trx according to the given routing table.
val make_from_addrs : (Ip.Addr.t * Eth.Addr.t) BatEnum.t ->
(route * int) array -> t * Tools.trx array