mirror of
https://github.com/mirage/qubes-mirage-firewall.git
synced 2025-02-06 10:25:22 -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 *)
|
(* The routing table *)
|
||||||
|
|
||||||
type t = {
|
type t = {
|
||||||
|
config : Dao.network_config;
|
||||||
clients : Client_eth.t;
|
clients : Client_eth.t;
|
||||||
nat : My_nat.t;
|
nat : My_nat.t;
|
||||||
uplink : interface;
|
uplink : interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
let create ~clients ~uplink ~nat =
|
let create ~config ~clients ~uplink ~nat =
|
||||||
{ clients; nat; uplink }
|
{ config; clients; nat; uplink }
|
||||||
|
|
||||||
let target t buf =
|
let target t buf =
|
||||||
let dst_ip = buf.Ipv4_packet.dst in
|
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 remove_client t = Client_eth.remove_client t.clients
|
||||||
|
|
||||||
let classify t ip =
|
let classify t ip =
|
||||||
if ip = Ipaddr.V4 t.uplink#my_ip then `Firewall
|
if ip = Ipaddr.V4 t.config.our_ip then `Firewall
|
||||||
else if ip = Ipaddr.V4 t.uplink#other_ip then `NetVM
|
else if ip = Ipaddr.V4 t.config.netvm_ip then `NetVM
|
||||||
else (Client_eth.classify t.clients ip :> Packet.host)
|
else (Client_eth.classify t.clients ip :> Packet.host)
|
||||||
|
|
||||||
let resolve t = function
|
let resolve t = function
|
||||||
| `Firewall -> Ipaddr.V4 t.uplink#my_ip
|
| `Firewall -> Ipaddr.V4 t.config.our_ip
|
||||||
| `NetVM -> Ipaddr.V4 t.uplink#other_ip
|
| `NetVM -> Ipaddr.V4 t.config.netvm_ip
|
||||||
| #Client_eth.host as host -> Client_eth.resolve t.clients host
|
| #Client_eth.host as host -> Client_eth.resolve t.clients host
|
||||||
|
@ -6,15 +6,17 @@
|
|||||||
open Fw_utils
|
open Fw_utils
|
||||||
|
|
||||||
type t = private {
|
type t = private {
|
||||||
|
config : Dao.network_config;
|
||||||
clients : Client_eth.t;
|
clients : Client_eth.t;
|
||||||
nat : My_nat.t;
|
nat : My_nat.t;
|
||||||
uplink : interface;
|
uplink : interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
val create :
|
val create :
|
||||||
clients:Client_eth.t ->
|
config : Dao.network_config ->
|
||||||
uplink:interface ->
|
clients : Client_eth.t ->
|
||||||
nat:My_nat.t ->
|
uplink : interface ->
|
||||||
|
nat : My_nat.t ->
|
||||||
t
|
t
|
||||||
(** [create ~client_eth ~uplink ~nat] is a new routing table
|
(** [create ~client_eth ~uplink ~nat] is a new routing table
|
||||||
that routes packets outside of [client_eth] via [uplink]. *)
|
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 ->
|
Client_eth.create config >>= fun clients ->
|
||||||
(* Set up routing between networks and hosts *)
|
(* Set up routing between networks and hosts *)
|
||||||
let router = Router.create
|
let router = Router.create
|
||||||
|
~config
|
||||||
~clients
|
~clients
|
||||||
~uplink:(Uplink.interface uplink)
|
~uplink:(Uplink.interface uplink)
|
||||||
~nat
|
~nat
|
||||||
|
Loading…
x
Reference in New Issue
Block a user