mirror of
https://github.com/mirage/qubes-mirage-firewall.git
synced 2025-01-29 15:43:34 -05:00
add the network_config to the router
This commit is contained in:
parent
5a0711bb2d
commit
de9a1dbd1c
13
router.ml
13
router.ml
@ -6,13 +6,14 @@ open Fw_utils
|
||||
(* The routing table *)
|
||||
|
||||
type t = {
|
||||
config : Dao.network_config;
|
||||
clients : Client_eth.t;
|
||||
nat : My_nat.t;
|
||||
uplink : interface;
|
||||
}
|
||||
|
||||
let create ~clients ~uplink ~nat =
|
||||
{ clients; nat; uplink }
|
||||
let create ~config ~clients ~uplink ~nat =
|
||||
{ config; clients; nat; uplink }
|
||||
|
||||
let target t buf =
|
||||
let dst_ip = buf.Ipv4_packet.dst in
|
||||
@ -24,11 +25,11 @@ let add_client t = Client_eth.add_client t.clients
|
||||
let remove_client t = Client_eth.remove_client t.clients
|
||||
|
||||
let classify t ip =
|
||||
if ip = Ipaddr.V4 t.uplink#my_ip then `Firewall
|
||||
else if ip = Ipaddr.V4 t.uplink#other_ip then `NetVM
|
||||
if ip = Ipaddr.V4 t.config.our_ip then `Firewall
|
||||
else if ip = Ipaddr.V4 t.config.netvm_ip then `NetVM
|
||||
else (Client_eth.classify t.clients ip :> Packet.host)
|
||||
|
||||
let resolve t = function
|
||||
| `Firewall -> Ipaddr.V4 t.uplink#my_ip
|
||||
| `NetVM -> Ipaddr.V4 t.uplink#other_ip
|
||||
| `Firewall -> Ipaddr.V4 t.config.our_ip
|
||||
| `NetVM -> Ipaddr.V4 t.config.netvm_ip
|
||||
| #Client_eth.host as host -> Client_eth.resolve t.clients host
|
||||
|
@ -6,15 +6,17 @@
|
||||
open Fw_utils
|
||||
|
||||
type t = private {
|
||||
config : Dao.network_config;
|
||||
clients : Client_eth.t;
|
||||
nat : My_nat.t;
|
||||
uplink : interface;
|
||||
}
|
||||
|
||||
val create :
|
||||
clients:Client_eth.t ->
|
||||
uplink:interface ->
|
||||
nat:My_nat.t ->
|
||||
config : Dao.network_config ->
|
||||
clients : Client_eth.t ->
|
||||
uplink : interface ->
|
||||
nat : My_nat.t ->
|
||||
t
|
||||
(** [create ~client_eth ~uplink ~nat] is a new routing table
|
||||
that routes packets outside of [client_eth] via [uplink]. *)
|
||||
|
@ -55,6 +55,7 @@ module Main (R : Mirage_random.S)(Clock : Mirage_clock.MCLOCK)(Time : Mirage_tim
|
||||
Client_eth.create config >>= fun clients ->
|
||||
(* Set up routing between networks and hosts *)
|
||||
let router = Router.create
|
||||
~config
|
||||
~clients
|
||||
~uplink:(Uplink.interface uplink)
|
||||
~nat
|
||||
|
Loading…
x
Reference in New Issue
Block a user