nic_router: read seconds attributes generic

Issue #2590
This commit is contained in:
Martin Stein 2017-11-28 13:20:14 +01:00 committed by Christian Helmuth
parent 53c87d18ed
commit 564e6a6885
2 changed files with 19 additions and 10 deletions

View File

@ -23,23 +23,34 @@ using namespace Net;
using namespace Genode;
Microseconds Configuration::_init_rtt(Xml_node const node)
/***************
** Utilities **
***************/
Microseconds read_sec_attr(Xml_node const node,
char const *name,
unsigned long const default_sec)
{
unsigned rtt_sec = node.attribute_value("rtt_sec", 0UL);
if (!rtt_sec) {
warning("fall back to default rtt_sec=\"",
(unsigned)DEFAULT_RTT_SEC, "\"");
rtt_sec = DEFAULT_RTT_SEC;
unsigned long sec = node.attribute_value(name, 0UL);
if (!sec) {
warning("fall back to default value \"", default_sec,
"\" for attribute \"", name, "\"");
sec = default_sec;
}
return Microseconds(rtt_sec * 1000 * 1000);
return Microseconds(sec * 1000 * 1000);
}
/*******************
** Configuration **
*******************/
Configuration::Configuration(Xml_node const node,
Allocator &alloc)
:
_alloc(alloc), _verbose(node.attribute_value("verbose", false)),
_rtt(_init_rtt(node)), _node(node)
_rtt(read_sec_attr(node, "rtt_sec", DEFAULT_RTT_SEC)),
_node(node)
{
/* read domains */
node.for_each_sub_node("domain", [&] (Xml_node const node) {

View File

@ -35,8 +35,6 @@ class Net::Configuration
Domain_tree _domains;
Genode::Xml_node const _node;
Genode::Microseconds _init_rtt(Genode::Xml_node const node);
public:
enum { DEFAULT_RTT_SEC = 6 };