drivers/nic/mode: exception on malformed values

Ref #3961
This commit is contained in:
Martin Stein 2021-02-01 12:42:55 +01:00 committed by Norman Feske
parent e3783b00bb
commit a9c4ebc9e9

View File

@ -24,7 +24,7 @@ namespace Genode
inline Nic_driver_mode read_nic_driver_mode(Xml_node const &driver_cfg)
{
String<16> const mode_str {
driver_cfg.attribute_value("mode", String<16>("")) };
driver_cfg.attribute_value("mode", String<16>("default")) };
if (mode_str == "nic_server") {
@ -34,7 +34,12 @@ namespace Genode
return Nic_driver_mode::UPLINK_CLIENT;
}
return Nic_driver_mode::NIC_SERVER;
if (mode_str == "default") {
return Nic_driver_mode::NIC_SERVER;
}
class Bad_mode { };
throw Bad_mode { };
}
}