diff --git a/repos/gems/src/app/sculpt_manager/network.cc b/repos/gems/src/app/sculpt_manager/network.cc index 640f348510..648cb623be 100644 --- a/repos/gems/src/app/sculpt_manager/network.cc +++ b/repos/gems/src/app/sculpt_manager/network.cc @@ -29,6 +29,17 @@ void Sculpt::Network::_generate_nic_router_uplink(Xml_generator &xml, xml.attribute("udp-ports", "1000"); xml.attribute("icmp-ids", "1000"); }); + + auto tcp_forward = [&] (uint16_t port, auto const &domain, auto const &to) + { + xml.node("tcp-forward", [&] { + xml.attribute("port", port); + xml.attribute("domain", domain); + xml.attribute("to", to); }); + }; + + tcp_forward(80 /* HTTP */ , "http", "10.0.80.2"); + tcp_forward(23 /* telnet */ , "telnet", "10.0.23.2"); }); } @@ -113,6 +124,30 @@ void Sculpt::Network::_generate_nic_router_config() xml.attribute("domain", "uplink"); }); } }); + + auto tcp_service_domain = [&] (auto const &name, auto const &ip_prefix) + { + using Ip = String<16>; + + Ip const interface { ip_prefix, ".1/24" }, + dhcp_addr { ip_prefix, ".2" }; + + xml.node("policy", [&] { + xml.attribute("label", name); + xml.attribute("domain", name); }); + + gen_named_node(xml, "domain", name, [&] () { + xml.attribute("interface", interface); + xml.node("dhcp-server", [&] { + xml.attribute("ip_first", dhcp_addr); + xml.attribute("ip_last", dhcp_addr); + if (_nic_target.type() != Nic_target::DISCONNECTED) { + xml.attribute("dns_config_from", "uplink"); } + }); + }); + }; + tcp_service_domain("http", "10.0.80"); + tcp_service_domain("telnet", "10.0.23"); }); }