mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-16 07:27:35 +00:00
parent
fb454a28fe
commit
381a3406ba
@ -1765,12 +1765,6 @@ void Sculpt::Main::_handle_runtime_state()
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Re-attempt NIC-router configuration as the uplink may have become
|
||||
* available in the meantime.
|
||||
*/
|
||||
_network.reattempt_nic_router_config();
|
||||
|
||||
if (_deploy.update_child_conditions()) {
|
||||
reconfigure_runtime = true;
|
||||
regenerate_dialog = true;
|
||||
|
@ -68,6 +68,12 @@ struct Sculpt::Managed_config
|
||||
(_obj.*_handle)(_manual_config_rom.xml());
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void with_manual_config(FN const &fn) const
|
||||
{
|
||||
fn(_manual_config_rom.xml());
|
||||
}
|
||||
|
||||
/**
|
||||
* \return true if manually-managed configuration could be used
|
||||
*/
|
||||
|
@ -56,16 +56,6 @@ void Sculpt::Network::handle_key_press(Codepoint code)
|
||||
|
||||
void Sculpt::Network::_generate_nic_router_config()
|
||||
{
|
||||
if ((_nic_target.wired() && !_runtime_info.present_in_runtime("nic_drv"))
|
||||
|| (_nic_target.wifi() && !_runtime_info.present_in_runtime("wifi_drv"))) {
|
||||
|
||||
/* defer NIC router reconfiguration until the needed uplink is present */
|
||||
_nic_router_config_up_to_date = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_nic_router_config_up_to_date = true;
|
||||
|
||||
if (_nic_router_config.try_generate_manually_managed())
|
||||
return;
|
||||
|
||||
@ -164,50 +154,43 @@ void Sculpt::Network::_handle_nic_router_state()
|
||||
}
|
||||
|
||||
|
||||
void Sculpt::Network::_handle_nic_router_config(Xml_node config)
|
||||
void Sculpt::Network::_update_nic_target_from_config(Xml_node const &config)
|
||||
{
|
||||
Nic_target::Type target = _nic_target.managed_type;
|
||||
|
||||
_nic_target.policy = config.has_type("empty")
|
||||
? Nic_target::MANAGED : Nic_target::MANUAL;
|
||||
|
||||
if (_nic_target.manual()) {
|
||||
|
||||
/* obtain uplink information from configuration */
|
||||
target = Nic_target::LOCAL;
|
||||
|
||||
/* obtain uplink information from configuration */
|
||||
auto nic_target_from_config = [] (Xml_node const &config)
|
||||
{
|
||||
if (!config.has_sub_node("domain"))
|
||||
target = Nic_target::OFF;
|
||||
return Nic_target::OFF;
|
||||
|
||||
struct Break : Exception { };
|
||||
try {
|
||||
config.for_each_sub_node("domain", [&] (Xml_node domain) {
|
||||
Nic_target::Type result = Nic_target::LOCAL;
|
||||
|
||||
/* skip domains that are not called "uplink" */
|
||||
if (domain.attribute_value("name", String<16>()) != "uplink")
|
||||
return;
|
||||
config.for_each_sub_node("policy", [&] (Xml_node uplink) {
|
||||
|
||||
config.for_each_sub_node("policy", [&] (Xml_node uplink) {
|
||||
/* skip uplinks not assigned to a domain called "uplink" */
|
||||
if (uplink.attribute_value("domain", String<16>()) != "uplink")
|
||||
return;
|
||||
|
||||
/* skip uplinks not assigned to a domain called "uplink" */
|
||||
if (uplink.attribute_value("domain", String<16>()) != "uplink")
|
||||
return;
|
||||
if (uplink.attribute_value("label", String<16>()) == "nic_drv -> ")
|
||||
result = Nic_target::WIRED;
|
||||
|
||||
if (uplink.attribute_value("label", String<16>()) == "nic_drv -> ") {
|
||||
target = Nic_target::WIRED;
|
||||
throw Break();
|
||||
}
|
||||
if (uplink.attribute_value("label", String<16>()) == "wifi_drv -> ") {
|
||||
target = Nic_target::WIFI;
|
||||
throw Break();
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (Break) { }
|
||||
_nic_target.manual_type = target;
|
||||
}
|
||||
if (uplink.attribute_value("label", String<16>()) == "wifi_drv -> ")
|
||||
result = Nic_target::WIFI;
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
nic_target(target);
|
||||
if (_nic_target.manual())
|
||||
_nic_target.manual_type = nic_target_from_config(config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Sculpt::Network::_handle_nic_router_config(Xml_node config)
|
||||
{
|
||||
_update_nic_target_from_config(config);
|
||||
_generate_nic_router_config();
|
||||
_runtime_config_generator.generate_runtime_config();
|
||||
_menu_view.generate();
|
||||
@ -241,11 +224,9 @@ void Sculpt::Network::gen_runtime_start_nodes(Xml_generator &xml) const
|
||||
break;
|
||||
|
||||
case Nic_target::OFF:
|
||||
|
||||
break;
|
||||
|
||||
case Nic_target::UNDEFINED:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,6 @@ struct Sculpt::Network : Network_dialog::Action
|
||||
Nic_target _nic_target { };
|
||||
Nic_state _nic_state { };
|
||||
|
||||
bool _nic_router_config_up_to_date = false;
|
||||
|
||||
Wpa_passphrase wpa_passphrase { };
|
||||
|
||||
unsigned _nic_drv_version = 0;
|
||||
@ -135,11 +133,7 @@ struct Sculpt::Network : Network_dialog::Action
|
||||
wifi_disconnect();
|
||||
}
|
||||
|
||||
void reattempt_nic_router_config()
|
||||
{
|
||||
if (_nic_target.nic_router_needed() && !_nic_router_config_up_to_date)
|
||||
_generate_nic_router_config();
|
||||
}
|
||||
void _update_nic_target_from_config(Xml_node const &);
|
||||
|
||||
/**
|
||||
* Network_dialog::Action interface
|
||||
@ -235,14 +229,21 @@ struct Sculpt::Network : Network_dialog::Action
|
||||
_runtime_config_generator(runtime_config_generator),
|
||||
_runtime_info(runtime_info), _pci_info(pci_info)
|
||||
{
|
||||
_generate_nic_router_config();
|
||||
|
||||
/*
|
||||
* Subscribe to reports
|
||||
*/
|
||||
_wlan_accesspoints_rom.sigh(_wlan_accesspoints_handler);
|
||||
_wlan_state_rom .sigh(_wlan_state_handler);
|
||||
_nic_router_state_rom .sigh(_nic_router_state_handler);
|
||||
|
||||
/*
|
||||
* Evaluate and forward initial manually managed config
|
||||
*/
|
||||
_nic_router_config.with_manual_config([&] (Xml_node const &config) {
|
||||
_update_nic_target_from_config(config); });
|
||||
|
||||
if (_nic_target.manual())
|
||||
_generate_nic_router_config();
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user