From 591ed80dcff3630c2271d5785a897051d657c835 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Tue, 6 Dec 2016 14:39:17 +0100 Subject: [PATCH] NIC router: hand-over XML nodes by value Ref #2193 --- repos/os/src/server/nic_router/configuration.cc | 4 ++-- repos/os/src/server/nic_router/direct_rule.cc | 5 +---- repos/os/src/server/nic_router/direct_rule.h | 5 +++-- repos/os/src/server/nic_router/domain.cc | 16 ++++++++-------- repos/os/src/server/nic_router/domain.h | 8 ++++---- repos/os/src/server/nic_router/forward_rule.cc | 2 +- repos/os/src/server/nic_router/forward_rule.h | 2 +- repos/os/src/server/nic_router/ip_rule.cc | 2 +- repos/os/src/server/nic_router/ip_rule.h | 2 +- repos/os/src/server/nic_router/leaf_rule.cc | 4 ++-- repos/os/src/server/nic_router/leaf_rule.h | 4 ++-- repos/os/src/server/nic_router/nat_rule.cc | 2 +- repos/os/src/server/nic_router/nat_rule.h | 2 +- repos/os/src/server/nic_router/permit_rule.cc | 6 +++--- repos/os/src/server/nic_router/permit_rule.h | 6 +++--- repos/os/src/server/nic_router/transport_rule.cc | 6 +++--- repos/os/src/server/nic_router/transport_rule.h | 4 ++-- 17 files changed, 39 insertions(+), 41 deletions(-) diff --git a/repos/os/src/server/nic_router/configuration.cc b/repos/os/src/server/nic_router/configuration.cc index 08ecddb07e..597c548cd2 100644 --- a/repos/os/src/server/nic_router/configuration.cc +++ b/repos/os/src/server/nic_router/configuration.cc @@ -27,7 +27,7 @@ using namespace Genode; ** Utilities ** ***************/ -static unsigned read_rtt_sec(Xml_node const &node) +static unsigned read_rtt_sec(Xml_node const node) { unsigned const rtt_sec = node.attribute_value("rtt_sec", 0UL); if (!rtt_sec) { @@ -48,7 +48,7 @@ Configuration::Configuration(Xml_node const node, Allocator &alloc) _rtt_sec(read_rtt_sec(node)), _node(node) { /* read domains */ - node.for_each_sub_node("domain", [&] (Xml_node const &node) { + node.for_each_sub_node("domain", [&] (Xml_node const node) { try { _domains.insert(*new (_alloc) Domain(*this, node, _alloc)); } catch (Domain::Invalid) { warning("invalid domain"); } }); diff --git a/repos/os/src/server/nic_router/direct_rule.cc b/repos/os/src/server/nic_router/direct_rule.cc index abc6532999..9be63b9284 100644 --- a/repos/os/src/server/nic_router/direct_rule.cc +++ b/repos/os/src/server/nic_router/direct_rule.cc @@ -14,14 +14,11 @@ /* local includes */ #include -/* Genode includes */ -#include - using namespace Net; using namespace Genode; -Direct_rule_base::Direct_rule_base(Xml_node const &node) +Direct_rule_base::Direct_rule_base(Xml_node const node) : _dst(node.attribute_value("dst", Ipv4_address_prefix())) { diff --git a/repos/os/src/server/nic_router/direct_rule.h b/repos/os/src/server/nic_router/direct_rule.h index 52121fd685..2c08d733e4 100644 --- a/repos/os/src/server/nic_router/direct_rule.h +++ b/repos/os/src/server/nic_router/direct_rule.h @@ -17,6 +17,7 @@ /* Genode includes */ #include #include +#include /* local includes */ #include @@ -39,7 +40,7 @@ class Net::Direct_rule_base : public Rule public: - Direct_rule_base(Genode::Xml_node const &node); + Direct_rule_base(Genode::Xml_node const node); /********* @@ -61,7 +62,7 @@ template struct Net::Direct_rule : Direct_rule_base, Direct_rule_list::Element { - Direct_rule(Genode::Xml_node const &node) : Direct_rule_base(node) { } + Direct_rule(Genode::Xml_node const node) : Direct_rule_base(node) { } }; diff --git a/repos/os/src/server/nic_router/domain.cc b/repos/os/src/server/nic_router/domain.cc index 73616007a2..7b4f6577d1 100644 --- a/repos/os/src/server/nic_router/domain.cc +++ b/repos/os/src/server/nic_router/domain.cc @@ -39,7 +39,7 @@ Domain_avl_member::Domain_avl_member(Domain_name const &name, ** Domain_base ** *****************/ -Domain_base::Domain_base(Xml_node const &node) +Domain_base::Domain_base(Xml_node const node) : _name(Cstring(node.attribute("name").value_base(), node.attribute("name").value_size())) @@ -52,11 +52,11 @@ Domain_base::Domain_base(Xml_node const &node) void Domain::_read_forward_rules(Cstring const &protocol, Domain_tree &domains, - Xml_node const &node, + Xml_node const node, char const *type, Forward_rule_tree &rules) { - node.for_each_sub_node(type, [&] (Xml_node const &node) { + node.for_each_sub_node(type, [&] (Xml_node const node) { try { Forward_rule &rule = *new (_alloc) Forward_rule(domains, node); rules.insert(&rule); @@ -70,11 +70,11 @@ void Domain::_read_forward_rules(Cstring const &protocol, void Domain::_read_transport_rules(Cstring const &protocol, Domain_tree &domains, - Xml_node const &node, + Xml_node const node, char const *type, Transport_rule_list &rules) { - node.for_each_sub_node(type, [&] (Xml_node const &node) { + node.for_each_sub_node(type, [&] (Xml_node const node) { try { rules.insert(*new (_alloc) Transport_rule(domains, node, _alloc, protocol, _config)); @@ -90,7 +90,7 @@ void Domain::print(Output &output) const } -Domain::Domain(Configuration &config, Xml_node const &node, Allocator &alloc) +Domain::Domain(Configuration &config, Xml_node const node, Allocator &alloc) : Domain_base(node), _avl_member(_name, *this), _config(config), _node(node), _alloc(alloc), @@ -119,7 +119,7 @@ void Domain::create_rules(Domain_tree &domains) _read_transport_rules(udp_name(), domains, _node, "udp", _udp_rules); /* read NAT rules */ - _node.for_each_sub_node("nat", [&] (Xml_node const &node) { + _node.for_each_sub_node("nat", [&] (Xml_node const node) { try { _nat_rules.insert( new (_alloc) Nat_rule(domains, _tcp_port_alloc, @@ -128,7 +128,7 @@ void Domain::create_rules(Domain_tree &domains) catch (Rule::Invalid) { warning("invalid NAT rule"); } }); /* read IP rules */ - _node.for_each_sub_node("ip", [&] (Xml_node const &node) { + _node.for_each_sub_node("ip", [&] (Xml_node const node) { try { _ip_rules.insert(*new (_alloc) Ip_rule(domains, node)); } catch (Rule::Invalid) { warning("invalid IP rule"); } }); diff --git a/repos/os/src/server/nic_router/domain.h b/repos/os/src/server/nic_router/domain.h index 435c7720c0..b12a15a4fa 100644 --- a/repos/os/src/server/nic_router/domain.h +++ b/repos/os/src/server/nic_router/domain.h @@ -66,7 +66,7 @@ class Net::Domain_base Domain_name const _name; - Domain_base(Genode::Xml_node const &node); + Domain_base(Genode::Xml_node const node); }; @@ -93,13 +93,13 @@ class Net::Domain : public Domain_base void _read_forward_rules(Genode::Cstring const &protocol, Domain_tree &domains, - Genode::Xml_node const &node, + Genode::Xml_node const node, char const *type, Forward_rule_tree &rules); void _read_transport_rules(Genode::Cstring const &protocol, Domain_tree &domains, - Genode::Xml_node const &node, + Genode::Xml_node const node, char const *type, Transport_rule_list &rules); @@ -109,7 +109,7 @@ class Net::Domain : public Domain_base struct No_next_hop : Genode::Exception { }; Domain(Configuration &config, - Genode::Xml_node const &node, + Genode::Xml_node const node, Genode::Allocator &alloc); void create_rules(Domain_tree &domains); diff --git a/repos/os/src/server/nic_router/forward_rule.cc b/repos/os/src/server/nic_router/forward_rule.cc index 39c437cbb9..896ec3c4bd 100644 --- a/repos/os/src/server/nic_router/forward_rule.cc +++ b/repos/os/src/server/nic_router/forward_rule.cc @@ -33,7 +33,7 @@ void Forward_rule::print(Output &output) const } -Forward_rule::Forward_rule(Domain_tree &domains, Xml_node const &node) +Forward_rule::Forward_rule(Domain_tree &domains, Xml_node const node) : Leaf_rule(domains, node), _port(node.attribute_value("port", Port(0))), diff --git a/repos/os/src/server/nic_router/forward_rule.h b/repos/os/src/server/nic_router/forward_rule.h index 516441ceea..05bf82b886 100644 --- a/repos/os/src/server/nic_router/forward_rule.h +++ b/repos/os/src/server/nic_router/forward_rule.h @@ -41,7 +41,7 @@ class Net::Forward_rule : public Leaf_rule, public: - Forward_rule(Domain_tree &domains, Genode::Xml_node const &node); + Forward_rule(Domain_tree &domains, Genode::Xml_node const node); Forward_rule const &find_by_port(Port const port) const; diff --git a/repos/os/src/server/nic_router/ip_rule.cc b/repos/os/src/server/nic_router/ip_rule.cc index 2cd5708abf..f980e821c0 100644 --- a/repos/os/src/server/nic_router/ip_rule.cc +++ b/repos/os/src/server/nic_router/ip_rule.cc @@ -18,7 +18,7 @@ using namespace Net; using namespace Genode; -Ip_rule::Ip_rule(Domain_tree &domains, Xml_node const &node) +Ip_rule::Ip_rule(Domain_tree &domains, Xml_node const node) : Leaf_rule(domains, node), Direct_rule(node) diff --git a/repos/os/src/server/nic_router/ip_rule.h b/repos/os/src/server/nic_router/ip_rule.h index f9303e6602..346d91cdab 100644 --- a/repos/os/src/server/nic_router/ip_rule.h +++ b/repos/os/src/server/nic_router/ip_rule.h @@ -29,7 +29,7 @@ struct Net::Ip_rule : Leaf_rule, Direct_rule { public: - Ip_rule(Domain_tree &domains, Genode::Xml_node const &node); + Ip_rule(Domain_tree &domains, Genode::Xml_node const node); }; #endif /* _IP_RULE_H_ */ diff --git a/repos/os/src/server/nic_router/leaf_rule.cc b/repos/os/src/server/nic_router/leaf_rule.cc index 7e918ec7f5..41d9a2a070 100644 --- a/repos/os/src/server/nic_router/leaf_rule.cc +++ b/repos/os/src/server/nic_router/leaf_rule.cc @@ -20,7 +20,7 @@ using namespace Genode; Domain &Leaf_rule::_find_domain(Domain_tree &domains, - Xml_node const &node) + Xml_node const node) { try { return domains.find_by_name( @@ -31,7 +31,7 @@ Domain &Leaf_rule::_find_domain(Domain_tree &domains, } -Leaf_rule::Leaf_rule(Domain_tree &domains, Xml_node const &node) +Leaf_rule::Leaf_rule(Domain_tree &domains, Xml_node const node) : _domain(_find_domain(domains, node)) { } diff --git a/repos/os/src/server/nic_router/leaf_rule.h b/repos/os/src/server/nic_router/leaf_rule.h index 1e4b0f8142..02c0177268 100644 --- a/repos/os/src/server/nic_router/leaf_rule.h +++ b/repos/os/src/server/nic_router/leaf_rule.h @@ -33,11 +33,11 @@ class Net::Leaf_rule : public Rule Domain &_domain; static Domain &_find_domain(Domain_tree &domains, - Genode::Xml_node const &node); + Genode::Xml_node const node); public: - Leaf_rule(Domain_tree &domains, Genode::Xml_node const &node); + Leaf_rule(Domain_tree &domains, Genode::Xml_node const node); /*************** diff --git a/repos/os/src/server/nic_router/nat_rule.cc b/repos/os/src/server/nic_router/nat_rule.cc index 8c635ad040..b4274fdad6 100644 --- a/repos/os/src/server/nic_router/nat_rule.cc +++ b/repos/os/src/server/nic_router/nat_rule.cc @@ -35,7 +35,7 @@ bool Nat_rule::higher(Nat_rule *rule) Nat_rule::Nat_rule(Domain_tree &domains, Port_allocator &tcp_port_alloc, Port_allocator &udp_port_alloc, - Xml_node const &node) + Xml_node const node) : Leaf_rule(domains, node), _tcp_port_alloc(tcp_port_alloc, node.attribute_value("tcp-ports", 0UL)), diff --git a/repos/os/src/server/nic_router/nat_rule.h b/repos/os/src/server/nic_router/nat_rule.h index d6ff9b7395..11ee2238c9 100644 --- a/repos/os/src/server/nic_router/nat_rule.h +++ b/repos/os/src/server/nic_router/nat_rule.h @@ -43,7 +43,7 @@ class Net::Nat_rule : public Leaf_rule, Nat_rule(Domain_tree &domains, Port_allocator &tcp_port_alloc, Port_allocator &udp_port_alloc, - Genode::Xml_node const &node); + Genode::Xml_node const node); Nat_rule &find_by_domain(Domain &domain); diff --git a/repos/os/src/server/nic_router/permit_rule.cc b/repos/os/src/server/nic_router/permit_rule.cc index a483a559c4..d73da405d0 100644 --- a/repos/os/src/server/nic_router/permit_rule.cc +++ b/repos/os/src/server/nic_router/permit_rule.cc @@ -26,7 +26,7 @@ using namespace Genode; ** Permit_rule ** *****************/ -Permit_rule::Permit_rule(Domain_tree &domains, Xml_node const &node) +Permit_rule::Permit_rule(Domain_tree &domains, Xml_node const node) : Leaf_rule(domains, node) { } @@ -42,7 +42,7 @@ void Permit_any_rule::print(Output &output) const } -Permit_any_rule::Permit_any_rule(Domain_tree &domains, Xml_node const &node) +Permit_any_rule::Permit_any_rule(Domain_tree &domains, Xml_node const node) : Permit_rule(domains, node) { } @@ -65,7 +65,7 @@ void Permit_single_rule::print(Output &output) const Permit_single_rule::Permit_single_rule(Domain_tree &domains, - Xml_node const &node) + Xml_node const node) : Permit_rule(domains, node), _port(node.attribute_value("port", Port(0))) diff --git a/repos/os/src/server/nic_router/permit_rule.h b/repos/os/src/server/nic_router/permit_rule.h index 80fd104348..39e01e830b 100644 --- a/repos/os/src/server/nic_router/permit_rule.h +++ b/repos/os/src/server/nic_router/permit_rule.h @@ -34,7 +34,7 @@ namespace Net { struct Net::Permit_rule : Leaf_rule { - Permit_rule(Domain_tree &domains, Genode::Xml_node const &node); + Permit_rule(Domain_tree &domains, Genode::Xml_node const node); /********* @@ -47,7 +47,7 @@ struct Net::Permit_rule : Leaf_rule struct Net::Permit_any_rule : Permit_rule { - Permit_any_rule(Domain_tree &domains, Genode::Xml_node const &node); + Permit_any_rule(Domain_tree &domains, Genode::Xml_node const node); /********* @@ -68,7 +68,7 @@ class Net::Permit_single_rule : public Permit_rule, public: Permit_single_rule(Domain_tree &domains, - Genode::Xml_node const &node); + Genode::Xml_node const node); Permit_single_rule const &find_by_port(Port const port) const; diff --git a/repos/os/src/server/nic_router/transport_rule.cc b/repos/os/src/server/nic_router/transport_rule.cc index 84efa26ff8..a9138b6bbd 100644 --- a/repos/os/src/server/nic_router/transport_rule.cc +++ b/repos/os/src/server/nic_router/transport_rule.cc @@ -25,7 +25,7 @@ using namespace Genode; Permit_any_rule *Transport_rule::_read_permit_any(Domain_tree &domains, - Xml_node const &node, + Xml_node const node, Allocator &alloc) { try { @@ -39,7 +39,7 @@ Permit_any_rule *Transport_rule::_read_permit_any(Domain_tree &domains, Transport_rule::Transport_rule(Domain_tree &domains, - Xml_node const &node, + Xml_node const node, Allocator &alloc, Cstring const &protocol, Configuration &config) @@ -55,7 +55,7 @@ Transport_rule::Transport_rule(Domain_tree &domains, } /* read specific permit rules */ - node.for_each_sub_node("permit", [&] (Xml_node const &node) { + node.for_each_sub_node("permit", [&] (Xml_node const node) { try { Permit_single_rule &rule = *new (alloc) Permit_single_rule(domains, node); diff --git a/repos/os/src/server/nic_router/transport_rule.h b/repos/os/src/server/nic_router/transport_rule.h index 733efafa4c..770db6565f 100644 --- a/repos/os/src/server/nic_router/transport_rule.h +++ b/repos/os/src/server/nic_router/transport_rule.h @@ -37,13 +37,13 @@ class Net::Transport_rule : public Direct_rule static Permit_any_rule * _read_permit_any(Domain_tree &domains, - Genode::Xml_node const &node, + Genode::Xml_node const node, Genode::Allocator &alloc); public: Transport_rule(Domain_tree &domains, - Genode::Xml_node const &node, + Genode::Xml_node const node, Genode::Allocator &alloc, Genode::Cstring const &protocol, Configuration &config);