mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-29 15:44:02 +00:00
nic_router: remove reference utilities
The Reference and Const_reference utility were introduced in order to express that something is a reference (no null value) but can be changed dynamically (not possible with built-in C++ references). However, the idea of preventing every possibility for null pointer faults, with which the router was built initially, has not prevailed and using pointers instead of the utility saves logic and makes the code more readable to other C++ developers. Ref #4729
This commit is contained in:
parent
f7f171e457
commit
93c3f6371b
@ -25,12 +25,12 @@ Arp_waiter::Arp_waiter(Interface &src,
|
||||
Ipv4_address const &ip,
|
||||
Packet_descriptor const &packet)
|
||||
:
|
||||
_src_le(this), _src(src), _dst_le(this), _dst(dst), _ip(ip),
|
||||
_src_le(this), _src(src), _dst_le(this), _dst_ptr(&dst), _ip(ip),
|
||||
_packet(packet)
|
||||
{
|
||||
_src.arp_stats().alive++;
|
||||
_src.own_arp_waiters().insert(&_src_le);
|
||||
_dst().foreign_arp_waiters().insert(&_dst_le);
|
||||
_dst_ptr->foreign_arp_waiters().insert(&_dst_le);
|
||||
}
|
||||
|
||||
|
||||
@ -39,19 +39,19 @@ Arp_waiter::~Arp_waiter()
|
||||
_src.arp_stats().alive--;
|
||||
_src.arp_stats().destroyed++;
|
||||
_src.own_arp_waiters().remove(&_src_le);
|
||||
_dst().foreign_arp_waiters().remove(&_dst_le);
|
||||
_dst_ptr->foreign_arp_waiters().remove(&_dst_le);
|
||||
}
|
||||
|
||||
|
||||
void Arp_waiter::handle_config(Domain &dst)
|
||||
{
|
||||
_dst().foreign_arp_waiters().remove(&_dst_le);
|
||||
_dst = dst;
|
||||
_dst().foreign_arp_waiters().insert(&_dst_le);
|
||||
_dst_ptr->foreign_arp_waiters().remove(&_dst_le);
|
||||
_dst_ptr = &dst;
|
||||
_dst_ptr->foreign_arp_waiters().insert(&_dst_le);
|
||||
}
|
||||
|
||||
|
||||
void Arp_waiter::print(Output &output) const
|
||||
{
|
||||
Genode::print(output, "IP ", _ip, " DST ", _dst());
|
||||
Genode::print(output, "IP ", _ip, " DST ", *_dst_ptr);
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
/* local includes */
|
||||
#include <list.h>
|
||||
#include <reference.h>
|
||||
|
||||
/* Genode includes */
|
||||
#include <net/ipv4.h>
|
||||
@ -42,10 +41,16 @@ class Net::Arp_waiter
|
||||
Arp_waiter_list_element _src_le;
|
||||
Interface &_src;
|
||||
Arp_waiter_list_element _dst_le;
|
||||
Reference<Domain> _dst;
|
||||
Domain *_dst_ptr;
|
||||
Ipv4_address const _ip;
|
||||
Packet_descriptor const _packet;
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Arp_waiter(Arp_waiter const &);
|
||||
Arp_waiter &operator = (Arp_waiter const &);
|
||||
|
||||
public:
|
||||
|
||||
Arp_waiter(Interface &src,
|
||||
@ -72,7 +77,7 @@ class Net::Arp_waiter
|
||||
Interface &src() const { return _src; }
|
||||
Ipv4_address const &ip() const { return _ip; }
|
||||
Packet_descriptor const &packet() const { return _packet; }
|
||||
Domain &dst() { return _dst(); }
|
||||
Domain &dst() { return *_dst_ptr; }
|
||||
};
|
||||
|
||||
#endif /* _ARP_WAITER_H_ */
|
||||
|
@ -403,7 +403,7 @@ void Interface::_update_domain_object(Domain &new_domain) {
|
||||
|
||||
void Interface::attach_to_domain()
|
||||
{
|
||||
_config().domains().with_element(
|
||||
_config_ptr->domains().with_element(
|
||||
_policy.determine_domain_name(),
|
||||
[&] /* match_fn */ (Domain &domain)
|
||||
{
|
||||
@ -522,7 +522,7 @@ Packet_result Interface::_new_link(L3_protocol const protocol,
|
||||
[&] {
|
||||
new (_alloc)
|
||||
Tcp_link { *this, local_domain, local, remote_port_alloc_ptr, remote_domain,
|
||||
remote, _timer, _config(), protocol, _tcp_stats }; },
|
||||
remote, _timer, *_config_ptr, protocol, _tcp_stats }; },
|
||||
[&] { _try_emergency_free_quota(); },
|
||||
[&] {
|
||||
_tcp_stats.refused_for_ram++;
|
||||
@ -533,7 +533,7 @@ Packet_result Interface::_new_link(L3_protocol const protocol,
|
||||
[&] {
|
||||
new (_alloc)
|
||||
Udp_link { *this, local_domain, local, remote_port_alloc_ptr, remote_domain,
|
||||
remote, _timer, _config(), protocol, _udp_stats }; },
|
||||
remote, _timer, *_config_ptr, protocol, _udp_stats }; },
|
||||
[&] { _try_emergency_free_quota(); },
|
||||
[&] {
|
||||
_udp_stats.refused_for_ram++;
|
||||
@ -544,7 +544,7 @@ Packet_result Interface::_new_link(L3_protocol const protocol,
|
||||
[&] {
|
||||
new (_alloc)
|
||||
Icmp_link { *this, local_domain, local, remote_port_alloc_ptr, remote_domain,
|
||||
remote, _timer, _config(), protocol, _icmp_stats }; },
|
||||
remote, _timer, *_config_ptr, protocol, _icmp_stats }; },
|
||||
[&] { _try_emergency_free_quota(); },
|
||||
[&] {
|
||||
_icmp_stats.refused_for_ram++;
|
||||
@ -642,7 +642,7 @@ Packet_result Interface::_nat_link_and_pass(Ethernet_frame ð,
|
||||
local_domain,
|
||||
[&] /* handle_match */ (Nat_rule &nat)
|
||||
{
|
||||
if(_config().verbose()) {
|
||||
if(_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] using NAT rule: ", nat); }
|
||||
|
||||
Port src_port(0);
|
||||
@ -765,7 +765,7 @@ void Interface::_send_dhcp_reply(Dhcp_server const &dhcp_srv,
|
||||
void Interface::_release_dhcp_allocation(Dhcp_allocation &allocation,
|
||||
Domain &local_domain)
|
||||
{
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] release DHCP allocation: ", allocation); }
|
||||
|
||||
_dhcp_allocations.remove(allocation);
|
||||
@ -784,10 +784,10 @@ Packet_result Interface::_new_dhcp_allocation(Ethernet_frame ð,
|
||||
[&] {
|
||||
Dhcp_allocation &allocation = *new (_alloc)
|
||||
Dhcp_allocation { *this, ip, dhcp.client_mac(),
|
||||
_timer, _config().dhcp_offer_timeout() };
|
||||
_timer, _config_ptr->dhcp_offer_timeout() };
|
||||
|
||||
_dhcp_allocations.insert(allocation);
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] offer DHCP allocation: ", allocation); }
|
||||
|
||||
_send_dhcp_reply(dhcp_srv, eth.src(), dhcp.client_mac(),
|
||||
@ -831,7 +831,7 @@ Packet_result Interface::_handle_dhcp_request(Ethernet_frame ð,
|
||||
return;
|
||||
|
||||
} else {
|
||||
allocation.lifetime(_config().dhcp_offer_timeout());
|
||||
allocation.lifetime(_config_ptr->dhcp_offer_timeout());
|
||||
_send_dhcp_reply(dhcp_srv, eth.src(), dhcp.client_mac(),
|
||||
allocation.ip(),
|
||||
Dhcp_packet::Message_type::OFFER,
|
||||
@ -859,7 +859,7 @@ Packet_result Interface::_handle_dhcp_request(Ethernet_frame ð,
|
||||
{
|
||||
allocation.set_bound();
|
||||
allocation.lifetime(dhcp_srv.ip_lease_time());
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] bind DHCP allocation: ",
|
||||
allocation);
|
||||
}
|
||||
@ -1019,7 +1019,7 @@ void Interface::handle_interface_link_state()
|
||||
}
|
||||
});
|
||||
/* force report if configured */
|
||||
_config().with_report([&] (Report &r) { r.handle_interface_link_state(); });
|
||||
_config_ptr->with_report([&] (Report &r) { r.handle_interface_link_state(); });
|
||||
}
|
||||
|
||||
|
||||
@ -1077,7 +1077,7 @@ Packet_result Interface::_handle_icmp_query(Ethernet_frame ð,
|
||||
bool const client = local_side.is_client();
|
||||
Link_side &remote_side = client ? link.server() : link.client();
|
||||
Domain &remote_domain = remote_side.domain();
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] using ", l3_protocol_name(prot),
|
||||
" link: ", link);
|
||||
}
|
||||
@ -1105,7 +1105,7 @@ Packet_result Interface::_handle_icmp_query(Ethernet_frame ð,
|
||||
ip.dst(),
|
||||
[&] /* handle_match */ (Ip_rule const &rule)
|
||||
{
|
||||
if(_config().verbose()) {
|
||||
if(_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] using ICMP rule: ", rule); }
|
||||
|
||||
Domain &remote_domain = rule.domain();
|
||||
@ -1155,7 +1155,7 @@ Packet_result Interface::_handle_icmp_error(Ethernet_frame ð,
|
||||
Domain &remote_domain = remote_side.domain();
|
||||
|
||||
/* print out that the link is used */
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] using ",
|
||||
l3_protocol_name(embed_prot), " link: ", link);
|
||||
}
|
||||
@ -1219,7 +1219,7 @@ Packet_result Interface::_handle_icmp(Ethernet_frame ð,
|
||||
ip.dst() == local_intf.address &&
|
||||
local_domain.icmp_echo_server())
|
||||
{
|
||||
if(_config().verbose()) {
|
||||
if(_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] act as ICMP Echo server"); }
|
||||
|
||||
_send_icmp_echo_reply(eth, ip, icmp, prot_size, size_guard);
|
||||
@ -1250,9 +1250,9 @@ Packet_result Interface::_handle_ip(Ethernet_frame ð,
|
||||
ip.fragment_offset() != 0) {
|
||||
|
||||
_dropped_fragm_ipv4++;
|
||||
if (_config().icmp_type_3_code_on_fragm_ipv4() != Icmp_packet::Code::INVALID) {
|
||||
if (_config_ptr->icmp_type_3_code_on_fragm_ipv4() != Icmp_packet::Code::INVALID) {
|
||||
_send_icmp_dst_unreachable(
|
||||
local_intf, eth, ip, _config().icmp_type_3_code_on_fragm_ipv4());
|
||||
local_intf, eth, ip, _config_ptr->icmp_type_3_code_on_fragm_ipv4());
|
||||
}
|
||||
return packet_drop("fragmented IPv4 not supported");
|
||||
}
|
||||
@ -1331,7 +1331,7 @@ Packet_result Interface::_handle_ip(Ethernet_frame ð,
|
||||
client ? link.server() : link.client();
|
||||
|
||||
Domain &remote_domain = remote_side.domain();
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] using ", l3_protocol_name(prot),
|
||||
" link: ", link);
|
||||
}
|
||||
@ -1357,7 +1357,7 @@ Packet_result Interface::_handle_ip(Ethernet_frame ð,
|
||||
/* try to route via forward rules */
|
||||
if (local_id.dst_ip == local_intf.address) {
|
||||
_with_forward_rule(local_domain, prot, local_id.dst_port, [&] (Forward_rule const &rule) {
|
||||
if(_config().verbose()) {
|
||||
if(_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] using forward rule: ",
|
||||
l3_protocol_name(prot), " ", rule);
|
||||
}
|
||||
@ -1379,7 +1379,7 @@ Packet_result Interface::_handle_ip(Ethernet_frame ð,
|
||||
/* try to route via transport and permit rules */
|
||||
_with_transport_rule(local_domain, prot, local_id.dst_ip, local_id.dst_port,
|
||||
[&] (Transport_rule const &transport_rule, Permit_rule const &permit_rule) {
|
||||
if(_config().verbose()) {
|
||||
if(_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] using ",
|
||||
l3_protocol_name(prot), " rule: ",
|
||||
transport_rule, " ", permit_rule);
|
||||
@ -1402,7 +1402,7 @@ Packet_result Interface::_handle_ip(Ethernet_frame ð,
|
||||
ip.dst(),
|
||||
[&] /* handle_match */ (Ip_rule const &rule)
|
||||
{
|
||||
if(_config().verbose()) {
|
||||
if(_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] using IP rule: ", rule); }
|
||||
|
||||
Domain &remote_domain = rule.domain();
|
||||
@ -1474,7 +1474,7 @@ void Interface::_handle_arp_reply(Ethernet_frame ð,
|
||||
[&] /* handle_match */ (Arp_cache_entry const &)
|
||||
{
|
||||
/* check wether a matching ARP cache entry already exists */
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] ARP entry already exists"); }
|
||||
},
|
||||
[&] /* handle_no_match */ ()
|
||||
@ -1503,7 +1503,7 @@ void Interface::_handle_arp_reply(Ethernet_frame ð,
|
||||
* Packet targets IP local to the domain's subnet and doesn't target
|
||||
* the router. Thus, forward it to all other interfaces of the domain.
|
||||
*/
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] forward ARP reply for local IP "
|
||||
"to all interfaces of the sender domain"); }
|
||||
_domain_broadcast(eth, size_guard, local_domain);
|
||||
@ -1557,7 +1557,7 @@ Packet_result Interface::_handle_arp_request(Ethernet_frame ð,
|
||||
} else if (arp.dst_ip() == local_intf.address) {
|
||||
|
||||
/* ARP request for the routers IP at this domain */
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] answer ARP request for router IP "
|
||||
"with router MAC"); }
|
||||
_send_arp_reply(eth, arp);
|
||||
@ -1565,7 +1565,7 @@ Packet_result Interface::_handle_arp_request(Ethernet_frame ð,
|
||||
} else {
|
||||
|
||||
/* forward request to all other interfaces of the domain */
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] forward ARP request for local IP "
|
||||
"to all interfaces of the sender domain"); }
|
||||
_domain_broadcast(eth, size_guard, local_domain);
|
||||
@ -1582,7 +1582,7 @@ Packet_result Interface::_handle_arp_request(Ethernet_frame ð,
|
||||
} else {
|
||||
|
||||
/* try to act as gateway for the domain as none is configured */
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", local_domain, "] answer ARP request for foreign IP "
|
||||
"with router MAC"); }
|
||||
_send_arp_reply(eth, arp);
|
||||
@ -1617,7 +1617,7 @@ void Interface::_drop_packet(Packet_descriptor const &pkt, char const *reason)
|
||||
if (domain .verbose_packet_drop())
|
||||
log("[", domain, "] drop packet (", reason, ")"); },
|
||||
[&] /* no_domain_fn */ {
|
||||
if (_config().verbose())
|
||||
if (_config_ptr->verbose())
|
||||
log("[?] drop packet (", reason, ")"); });
|
||||
}
|
||||
|
||||
@ -1658,7 +1658,7 @@ void Interface::_handle_pkt_stream_signal()
|
||||
* applied. If there is no such limit, received packets are handled until
|
||||
* none is left.
|
||||
*/
|
||||
unsigned long const max_pkts = _config().max_packets_per_signal();
|
||||
unsigned long const max_pkts = _config_ptr->max_packets_per_signal();
|
||||
if (max_pkts) {
|
||||
for (unsigned long i = 0; _sink.packet_avail(); i++) {
|
||||
|
||||
@ -1689,7 +1689,7 @@ void Interface::_handle_pkt_stream_signal()
|
||||
* We therefore wakeup all sources and our sink. Note that the packet-stream
|
||||
* API takes care of emitting only the signals that are actually needed.
|
||||
*/
|
||||
_config().domains().for_each([&] (Domain &domain) {
|
||||
_config_ptr->domains().for_each([&] (Domain &domain) {
|
||||
domain.interfaces().for_each([&] (Interface &interface) {
|
||||
interface.wakeup_source();
|
||||
});
|
||||
@ -1819,7 +1819,7 @@ Packet_result Interface::_handle_eth(void *const eth_base,
|
||||
result = _handle_eth(eth, size_guard, pkt, domain);
|
||||
};
|
||||
auto no_domain_fn = [&] /* no_domain_fn */ {
|
||||
if (_config().verbose_packets())
|
||||
if (_config_ptr->verbose_packets())
|
||||
log("[?] rcv ", eth);
|
||||
result = packet_drop("no domain");
|
||||
};
|
||||
@ -1880,20 +1880,20 @@ Interface::Interface(Genode::Entrypoint &ep,
|
||||
_pkt_stream_signal_handler { ep, *this, &Interface::_handle_pkt_stream_signal },
|
||||
_router_mac { router_mac },
|
||||
_mac { mac },
|
||||
_config { config },
|
||||
_config_ptr { &config },
|
||||
_policy { policy },
|
||||
_timer { timer },
|
||||
_alloc { alloc },
|
||||
_interfaces { interfaces }
|
||||
{
|
||||
_interfaces.insert(this);
|
||||
_config().with_report([&] (Report &r) { r.handle_interface_link_state(); });
|
||||
_config_ptr->with_report([&] (Report &r) { r.handle_interface_link_state(); });
|
||||
}
|
||||
|
||||
|
||||
void Interface::_dismiss_link(Link &link)
|
||||
{
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", link.client().domain(), "] dismiss link client: ", link.client());
|
||||
log("[", link.server().domain(), "] dismiss link server: ", link.server());
|
||||
}
|
||||
@ -1912,7 +1912,7 @@ bool Interface::_try_update_link(Link &link,
|
||||
return false;
|
||||
|
||||
if (link.client().src_ip() == link.server().dst_ip()) {
|
||||
link.handle_config(cln_dom, new_srv_dom, nullptr, _config());
|
||||
link.handle_config(cln_dom, new_srv_dom, nullptr, *_config_ptr);
|
||||
return true;
|
||||
}
|
||||
if (link.server().dst_ip() != new_srv_dom.ip_config().interface().address)
|
||||
@ -1927,7 +1927,7 @@ bool Interface::_try_update_link(Link &link,
|
||||
if (!remote_port_alloc.alloc(link.server().dst_port()))
|
||||
return;
|
||||
|
||||
link.handle_config(cln_dom, new_srv_dom, &remote_port_alloc, _config());
|
||||
link.handle_config(cln_dom, new_srv_dom, &remote_port_alloc, *_config_ptr);
|
||||
keep_link = true;
|
||||
},
|
||||
[&] /* handle_no_match */ () { }
|
||||
@ -2011,7 +2011,7 @@ void Interface::_update_dhcp_allocations(Domain &old_domain,
|
||||
/* try to re-use existing DHCP allocations */
|
||||
_dhcp_allocations.for_each([&] (Dhcp_allocation &allocation) {
|
||||
if (!new_dhcp_srv.alloc_ip(allocation.ip())) {
|
||||
if (_config().verbose())
|
||||
if (_config_ptr->verbose())
|
||||
log("[", new_domain, "] dismiss DHCP allocation: ", allocation, " (no IP)");
|
||||
|
||||
dhcp_clients_outdated = true;
|
||||
@ -2019,14 +2019,14 @@ void Interface::_update_dhcp_allocations(Domain &old_domain,
|
||||
_destroy_dhcp_allocation(allocation, old_domain);
|
||||
return;
|
||||
}
|
||||
if (_config().verbose())
|
||||
if (_config_ptr->verbose())
|
||||
log("[", new_domain, "] update DHCP allocation: ", allocation);
|
||||
});
|
||||
} else {
|
||||
/* dismiss all DHCP allocations */
|
||||
dhcp_clients_outdated = true;
|
||||
while (Dhcp_allocation *allocation = _dhcp_allocations.first()) {
|
||||
if (_config().verbose())
|
||||
if (_config_ptr->verbose())
|
||||
log("[", new_domain, "] dismiss DHCP allocation: ",
|
||||
*allocation, " (other/no DHCP server)");
|
||||
_dhcp_allocations.remove(*allocation);
|
||||
@ -2041,12 +2041,12 @@ void Interface::_update_dhcp_allocations(Domain &old_domain,
|
||||
|
||||
void Interface::_update_own_arp_waiters(Domain &domain)
|
||||
{
|
||||
bool const verbose { _config().verbose() };
|
||||
bool const verbose { _config_ptr->verbose() };
|
||||
_own_arp_waiters.for_each([&] (Arp_waiter_list_element &le)
|
||||
{
|
||||
Arp_waiter &arp_waiter { *le.object() };
|
||||
bool dismiss_arp_waiter { true };
|
||||
_config().domains().with_element(
|
||||
_config_ptr->domains().with_element(
|
||||
arp_waiter.dst().name(),
|
||||
[&] /* match_fn */ (Domain &dst)
|
||||
{
|
||||
@ -2079,7 +2079,7 @@ void Interface::_update_own_arp_waiters(Domain &domain)
|
||||
void Interface::handle_config_1(Configuration &config)
|
||||
{
|
||||
/* update config and policy */
|
||||
_config = config;
|
||||
_config_ptr = &config;
|
||||
_policy.handle_config(config);
|
||||
Domain_name const &new_domain_name = _policy.determine_domain_name();
|
||||
with_domain([&] (Domain &old_domain) {
|
||||
@ -2109,21 +2109,21 @@ void Interface::handle_config_1(Configuration &config)
|
||||
|
||||
void Interface::_failed_to_send_packet_link()
|
||||
{
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", *_domain_ptr, "] failed to send packet (link down)"); }
|
||||
}
|
||||
|
||||
|
||||
void Interface::_failed_to_send_packet_submit()
|
||||
{
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", *_domain_ptr, "] failed to send packet (queue full)"); }
|
||||
}
|
||||
|
||||
|
||||
void Interface::_failed_to_send_packet_alloc()
|
||||
{
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", *_domain_ptr, "] failed to send packet (packet alloc failed)"); }
|
||||
}
|
||||
|
||||
@ -2132,7 +2132,7 @@ void Interface::handle_config_2()
|
||||
{
|
||||
Domain_name const &new_domain_name = _policy.determine_domain_name();
|
||||
auto domain_fn = [&] (Domain &old_domain) {
|
||||
_config().domains().with_element(
|
||||
_config_ptr->domains().with_element(
|
||||
new_domain_name,
|
||||
[&] /* match_fn */ (Domain &new_domain)
|
||||
{
|
||||
@ -2182,7 +2182,7 @@ void Interface::handle_config_2()
|
||||
};
|
||||
auto no_domain_fn = [&] {
|
||||
/* the interface had no domain but now it may get one */
|
||||
_config().domains().with_element(
|
||||
_config_ptr->domains().with_element(
|
||||
new_domain_name,
|
||||
[&] /* match_fn */ (Domain &new_domain)
|
||||
{
|
||||
@ -2239,7 +2239,7 @@ void Interface::handle_config_3()
|
||||
void Interface::_ack_packet(Packet_descriptor const &pkt)
|
||||
{
|
||||
if (!_sink.try_ack_packet(pkt)) {
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[", *_domain_ptr, "] leak packet (sink not ready to "
|
||||
"acknowledge)");
|
||||
}
|
||||
@ -2257,7 +2257,7 @@ void Interface::cancel_arp_waiting(Arp_waiter &waiter)
|
||||
|
||||
Interface::~Interface()
|
||||
{
|
||||
_config().with_report([&] (Report &r) { r.handle_interface_link_state(); });
|
||||
_config_ptr->with_report([&] (Report &r) { r.handle_interface_link_state(); });
|
||||
_detach_from_domain();
|
||||
_interfaces.remove(this);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ class Net::Interface : private Interface_list::Element
|
||||
Signal_handler _pkt_stream_signal_handler;
|
||||
Mac_address const _router_mac;
|
||||
Mac_address const _mac;
|
||||
Reference<Configuration> _config;
|
||||
Configuration *_config_ptr;
|
||||
Interface_policy &_policy;
|
||||
Cached_timer &_timer;
|
||||
Genode::Allocator &_alloc;
|
||||
@ -469,7 +469,7 @@ class Net::Interface : private Interface_list::Element
|
||||
** Accessors **
|
||||
***************/
|
||||
|
||||
Configuration const &config() const { return _config(); }
|
||||
Configuration const &config() const { return *_config_ptr; }
|
||||
Mac_address const &router_mac() const { return _router_mac; }
|
||||
Mac_address const &mac() const { return _mac; }
|
||||
Arp_waiter_list &own_arp_waiters() { return _own_arp_waiters; }
|
||||
|
@ -53,7 +53,7 @@ Link_side::Link_side(Domain &domain,
|
||||
Link_side_id const &id,
|
||||
Link &link)
|
||||
:
|
||||
_domain(domain), _id(id), _link(link)
|
||||
_domain_ptr(&domain), _id(id), _link(link)
|
||||
{
|
||||
if (link.config().verbose()) {
|
||||
log("[", domain, "] new ", l3_protocol_name(link.protocol()),
|
||||
@ -97,7 +97,7 @@ Link::Link(Interface &cln_interface,
|
||||
Microseconds const dissolve_timeout,
|
||||
Interface_link_stats &stats)
|
||||
:
|
||||
_config(config),
|
||||
_config_ptr(&config),
|
||||
_client_interface(cln_interface),
|
||||
_server_port_alloc_ptr(srv_port_alloc_ptr),
|
||||
_dissolve_timeout(timer, *this, &Link::_handle_dissolve_timeout,
|
||||
@ -107,9 +107,9 @@ Link::Link(Interface &cln_interface,
|
||||
_client(cln_domain, cln_id, *this),
|
||||
_server(srv_domain, srv_id, *this),
|
||||
_stats(stats),
|
||||
_stats_curr(stats.opening)
|
||||
_stats_ptr(&stats.opening)
|
||||
{
|
||||
_stats_curr()++;
|
||||
(*_stats_ptr)++;
|
||||
_client_interface.links(_protocol).insert(this);
|
||||
_client.domain().links(_protocol).insert(&_client);
|
||||
_server.domain().links(_protocol).insert(&_server);
|
||||
@ -131,24 +131,24 @@ void Link::_handle_dissolve_timeout(Duration)
|
||||
void Link::dissolve(bool timeout)
|
||||
{
|
||||
|
||||
_stats_curr()--;
|
||||
(*_stats_ptr)--;
|
||||
if (timeout) {
|
||||
if (&_stats_curr() == &_stats.opening) { _stats_curr = _stats.dissolved_timeout_opening; }
|
||||
if (&_stats_curr() == &_stats.open) { _stats_curr = _stats.dissolved_timeout_open; }
|
||||
if (&_stats_curr() == &_stats.closing) { _stats_curr = _stats.dissolved_timeout_closing; }
|
||||
if (&_stats_curr() == &_stats.closed) { _stats_curr = _stats.dissolved_timeout_closed; }
|
||||
if (_stats_ptr == &_stats.opening) { _stats_ptr = &_stats.dissolved_timeout_opening; }
|
||||
if (_stats_ptr == &_stats.open) { _stats_ptr = &_stats.dissolved_timeout_open; }
|
||||
if (_stats_ptr == &_stats.closing) { _stats_ptr = &_stats.dissolved_timeout_closing; }
|
||||
if (_stats_ptr == &_stats.closed) { _stats_ptr = &_stats.dissolved_timeout_closed; }
|
||||
} else {
|
||||
_stats_curr = _stats.dissolved_no_timeout;
|
||||
_stats_ptr = &_stats.dissolved_no_timeout;
|
||||
}
|
||||
_stats_curr()++;
|
||||
(*_stats_ptr)++;
|
||||
|
||||
_client.domain().links(_protocol).remove(&_client);
|
||||
_server.domain().links(_protocol).remove(&_server);
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("Dissolve ", l3_protocol_name(_protocol), " link: ", *this); }
|
||||
|
||||
if (_server_port_alloc_ptr) {
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("Free ", l3_protocol_name(_protocol),
|
||||
" port ", _server.dst_port(),
|
||||
" at ", _server.domain(),
|
||||
@ -177,9 +177,9 @@ void Link::handle_config(Domain &cln_domain,
|
||||
_client.domain().links(_protocol).remove(&_client);
|
||||
_server.domain().links(_protocol).remove(&_server);
|
||||
|
||||
_config = config;
|
||||
_client._domain = cln_domain;
|
||||
_server._domain = srv_domain;
|
||||
_config_ptr = &config;
|
||||
_client._domain_ptr = &cln_domain;
|
||||
_server._domain_ptr = &srv_domain;
|
||||
_server_port_alloc_ptr = srv_port_alloc_ptr;
|
||||
|
||||
cln_domain.links(_protocol).insert(&_client);
|
||||
@ -215,18 +215,18 @@ Tcp_link::Tcp_link(Interface &cln_interface,
|
||||
void Tcp_link::_closing()
|
||||
{
|
||||
_state = State::CLOSING;
|
||||
_stats_curr()--;
|
||||
_stats_curr = _stats.closing;
|
||||
_stats_curr()++;
|
||||
(*_stats_ptr)--;
|
||||
_stats_ptr = &_stats.closing;
|
||||
(*_stats_ptr)++;
|
||||
}
|
||||
|
||||
|
||||
void Tcp_link::_closed()
|
||||
{
|
||||
_state = State::CLOSED;
|
||||
_stats_curr()--;
|
||||
_stats_curr = _stats.closed;
|
||||
_stats_curr()++;
|
||||
(*_stats_ptr)--;
|
||||
_stats_ptr = &_stats.closed;
|
||||
(*_stats_ptr)++;
|
||||
}
|
||||
|
||||
|
||||
@ -257,7 +257,7 @@ void Tcp_link::_tcp_packet(Tcp_packet &tcp,
|
||||
_packet();
|
||||
} else {
|
||||
_dissolve_timeout.schedule(
|
||||
Microseconds(_config().tcp_max_segm_lifetime().value << 1));
|
||||
Microseconds(_config_ptr->tcp_max_segm_lifetime().value << 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,9 +267,9 @@ void Tcp_link::server_packet(Tcp_packet &tcp)
|
||||
if (_opening) {
|
||||
_opening = false;
|
||||
_state = State::OPEN;
|
||||
_stats_curr()--;
|
||||
if (&_stats_curr() == &_stats.opening) { _stats_curr = _stats.open; }
|
||||
_stats_curr()++;
|
||||
(*_stats_ptr)--;
|
||||
if (_stats_ptr == &_stats.opening) { _stats_ptr = &_stats.open; }
|
||||
(*_stats_ptr)++;
|
||||
}
|
||||
_tcp_packet(tcp, _server, _client);
|
||||
}
|
||||
@ -299,9 +299,9 @@ void Udp_link::server_packet()
|
||||
{
|
||||
if (_opening) {
|
||||
_opening = false;
|
||||
_stats_curr()--;
|
||||
if (&_stats_curr() == &_stats.opening) { _stats_curr = _stats.open; }
|
||||
_stats_curr()++;
|
||||
(*_stats_ptr)--;
|
||||
if (_stats_ptr == &_stats.opening) { _stats_ptr = &_stats.open; }
|
||||
(*_stats_ptr)++;
|
||||
}
|
||||
_packet();
|
||||
}
|
||||
@ -331,9 +331,10 @@ void Icmp_link::server_packet()
|
||||
{
|
||||
if (_opening) {
|
||||
_opening = false;
|
||||
_stats_curr()--;
|
||||
if (&_stats_curr() == &_stats.opening) { _stats_curr = _stats.open; }
|
||||
_stats_curr()++;
|
||||
(*_stats_ptr)--;
|
||||
if (_stats_ptr == &_stats.opening)
|
||||
_stats_ptr = &_stats.open;
|
||||
(*_stats_ptr)++;
|
||||
}
|
||||
_packet();
|
||||
}
|
||||
|
@ -39,7 +39,6 @@
|
||||
|
||||
/* local includes */
|
||||
#include <list.h>
|
||||
#include <reference.h>
|
||||
#include <l3_protocol.h>
|
||||
#include <lazy_one_shot_timeout.h>
|
||||
|
||||
@ -91,10 +90,16 @@ class Net::Link_side : public Genode::Avl_node<Link_side>
|
||||
|
||||
private:
|
||||
|
||||
Reference<Domain> _domain;
|
||||
Domain *_domain_ptr;
|
||||
Link_side_id const _id;
|
||||
Link &_link;
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Link_side(Link_side const &);
|
||||
Link_side &operator = (Link_side const &);
|
||||
|
||||
public:
|
||||
|
||||
Link_side(Domain &domain,
|
||||
@ -150,7 +155,7 @@ class Net::Link_side : public Genode::Avl_node<Link_side>
|
||||
** Accessors **
|
||||
***************/
|
||||
|
||||
Domain &domain() const { return _domain(); }
|
||||
Domain &domain() const { return *_domain_ptr; }
|
||||
Link &link() const { return _link; }
|
||||
Ipv4_address const &src_ip() const { return _id.src_ip; }
|
||||
Ipv4_address const &dst_ip() const { return _id.dst_ip; }
|
||||
@ -184,7 +189,7 @@ class Net::Link : public Link_list::Element
|
||||
{
|
||||
protected:
|
||||
|
||||
Reference<Configuration> _config;
|
||||
Configuration *_config_ptr;
|
||||
Interface &_client_interface;
|
||||
Port_allocator_guard *_server_port_alloc_ptr;
|
||||
Lazy_one_shot_timeout<Link> _dissolve_timeout;
|
||||
@ -194,7 +199,7 @@ class Net::Link : public Link_list::Element
|
||||
Link_side _server;
|
||||
bool _opening { true };
|
||||
Interface_link_stats &_stats;
|
||||
Reference<Genode::size_t> _stats_curr;
|
||||
Genode::size_t *_stats_ptr;
|
||||
|
||||
void _handle_dissolve_timeout(Genode::Duration);
|
||||
|
||||
@ -246,7 +251,7 @@ class Net::Link : public Link_list::Element
|
||||
Link_side const &client() const { return _client; }
|
||||
Link_side &server() { return _server; }
|
||||
Link_side const &server() const { return _server; }
|
||||
Configuration &config() { return _config(); }
|
||||
Configuration &config() { return *_config_ptr; }
|
||||
L3_protocol protocol() const { return _protocol; }
|
||||
Interface &client_interface() { return _client_interface; };
|
||||
};
|
||||
|
@ -40,10 +40,16 @@ class Net::Main
|
||||
Genode::Heap _heap { &_env.ram(), &_env.rm() };
|
||||
Signal_handler<Main> _report_handler { _env.ep(), *this, &Main::_handle_report };
|
||||
Genode::Attached_rom_dataspace _config_rom { _env, "config" };
|
||||
Reference<Configuration> _config { *new (_heap) Configuration { _config_rom.xml(), _heap } };
|
||||
Configuration *_config_ptr { new (_heap) Configuration { _config_rom.xml(), _heap } };
|
||||
Signal_handler<Main> _config_handler { _env.ep(), *this, &Main::_handle_config };
|
||||
Nic_session_root _nic_session_root { _env, _timer, _heap, _config(), _shared_quota, _interfaces };
|
||||
Uplink_session_root _uplink_session_root { _env, _timer, _heap, _config(), _shared_quota, _interfaces };
|
||||
Nic_session_root _nic_session_root { _env, _timer, _heap, *_config_ptr, _shared_quota, _interfaces };
|
||||
Uplink_session_root _uplink_session_root { _env, _timer, _heap, *_config_ptr, _shared_quota, _interfaces };
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Main(Main const &);
|
||||
Main &operator = (Main const &);
|
||||
|
||||
void _handle_report();
|
||||
|
||||
@ -55,7 +61,7 @@ class Net::Main
|
||||
_interfaces.for_each([&] (Interface &interface) {
|
||||
functor(interface);
|
||||
});
|
||||
_config().domains().for_each([&] (Domain &domain) {
|
||||
_config_ptr->domains().for_each([&] (Domain &domain) {
|
||||
domain.interfaces().for_each([&] (Interface &interface) {
|
||||
functor(interface);
|
||||
});
|
||||
@ -70,7 +76,7 @@ class Net::Main
|
||||
|
||||
void Main::_handle_report()
|
||||
{
|
||||
_config().with_report([&] (Report &r) { r.generate(); });
|
||||
_config_ptr->with_report([&] (Report &r) { r.generate(); });
|
||||
}
|
||||
|
||||
|
||||
@ -86,7 +92,7 @@ Net::Main::Main(Env &env) : _env(env)
|
||||
void Net::Main::_handle_config()
|
||||
{
|
||||
_config_rom.update();
|
||||
Configuration &old_config = _config();
|
||||
Configuration &old_config = *_config_ptr;
|
||||
Configuration &new_config = *new (_heap)
|
||||
Configuration {
|
||||
_env, _config_rom.xml(), _heap, _report_handler, _timer,
|
||||
@ -96,7 +102,7 @@ void Net::Main::_handle_config()
|
||||
_uplink_session_root.handle_config(new_config);
|
||||
_for_each_interface([&] (Interface &intf) { intf.handle_config_1(new_config); });
|
||||
_for_each_interface([&] (Interface &intf) { intf.handle_config_2(); });
|
||||
_config = Reference<Configuration>(new_config);
|
||||
_config_ptr = &new_config;
|
||||
_for_each_interface([&] (Interface &intf) { intf.handle_config_3(); });
|
||||
|
||||
destroy(_heap, &old_config);
|
||||
|
@ -100,7 +100,7 @@ Net::Nic_client_interface_base::
|
||||
Session_label const &label,
|
||||
bool const &session_link_state)
|
||||
:
|
||||
_domain_name { domain_name },
|
||||
_domain_name_ptr { &domain_name },
|
||||
_label { label },
|
||||
_session_link_state { session_link_state }
|
||||
{ }
|
||||
|
@ -80,17 +80,23 @@ class Net::Nic_client_interface_base : public Interface_policy
|
||||
{
|
||||
private:
|
||||
|
||||
Const_reference<Domain_name> _domain_name;
|
||||
Genode::Session_label const _label;
|
||||
bool const &_session_link_state;
|
||||
bool _domain_ready { false };
|
||||
Domain_name const *_domain_name_ptr;
|
||||
Genode::Session_label const _label;
|
||||
bool const &_session_link_state;
|
||||
bool _domain_ready { false };
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Nic_client_interface_base(Nic_client_interface_base const &);
|
||||
Nic_client_interface_base &operator = (Nic_client_interface_base const &);
|
||||
|
||||
|
||||
/***************************
|
||||
** Net::Interface_policy **
|
||||
***************************/
|
||||
|
||||
Domain_name determine_domain_name() const override { return _domain_name(); };
|
||||
Domain_name determine_domain_name() const override { return *_domain_name_ptr; };
|
||||
void handle_config(Configuration const &) override { }
|
||||
Genode::Session_label const &label() const override { return _label; }
|
||||
void handle_domain_ready_state(bool state) override;
|
||||
@ -111,7 +117,7 @@ class Net::Nic_client_interface_base : public Interface_policy
|
||||
** Accessors **
|
||||
***************/
|
||||
|
||||
void domain_name(Domain_name const &v) { _domain_name = v; }
|
||||
void domain_name(Domain_name const &v) { _domain_name_ptr = &v; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ Interface_policy::Interface_policy(Genode::Session_label const &label,
|
||||
Configuration const &config)
|
||||
:
|
||||
_label { label },
|
||||
_config { config },
|
||||
_config_ptr { &config },
|
||||
_session_env { session_env }
|
||||
{
|
||||
_session_link_state_transition(DOWN);
|
||||
@ -62,13 +62,13 @@ Net::Nic_session_component::Interface_policy::determine_domain_name() const
|
||||
{
|
||||
Domain_name domain_name { };
|
||||
try {
|
||||
Session_policy policy(_label, _config().node());
|
||||
Session_policy policy(_label, _config_ptr->node());
|
||||
domain_name = policy.attribute_value("domain", Domain_name());
|
||||
if (domain_name == Domain_name() && _config().verbose())
|
||||
if (domain_name == Domain_name() && _config_ptr->verbose())
|
||||
log("[?] no domain attribute in policy for downlink label \"", _label, "\"");
|
||||
}
|
||||
catch (Session_policy::No_policy_defined) {
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[?] no policy for downlink label \"", _label, "\""); }
|
||||
}
|
||||
return domain_name;
|
||||
@ -290,7 +290,7 @@ Net::Nic_session_root::Nic_session_root(Env &env,
|
||||
_env { env },
|
||||
_timer { timer },
|
||||
_mac_alloc { MAC_ALLOC_BASE },
|
||||
_config { config },
|
||||
_config_ptr { &config },
|
||||
_shared_quota { shared_quota },
|
||||
_interfaces { interfaces }
|
||||
{
|
||||
@ -318,7 +318,7 @@ Nic_session_component *Net::Nic_session_root::_create_session(char const *args)
|
||||
Arg_string::find_arg(args, "tx_buf_size").ulong_value(0),
|
||||
Arg_string::find_arg(args, "rx_buf_size").ulong_value(0),
|
||||
_timer, mac, *_router_mac, label, _interfaces,
|
||||
_config(), ram_ds);
|
||||
*_config_ptr, ram_ds);
|
||||
}
|
||||
catch (...) {
|
||||
_mac_alloc.free(mac);
|
||||
@ -380,6 +380,6 @@ void Net::Nic_session_root::_destroy_session(Nic_session_component *session)
|
||||
|
||||
void Net::Nic_session_root::_invalid_downlink(char const *reason)
|
||||
{
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[?] invalid downlink (", reason, ")"); }
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
/* local includes */
|
||||
#include <mac_allocator.h>
|
||||
#include <interface.h>
|
||||
#include <reference.h>
|
||||
#include <report.h>
|
||||
#include <session_env.h>
|
||||
#include <communication_buffer.h>
|
||||
@ -91,11 +90,17 @@ class Net::Nic_session_component : private Nic_session_component_base,
|
||||
UP_DOWN_UP
|
||||
};
|
||||
|
||||
Genode::Session_label const _label;
|
||||
Const_reference<Configuration> _config;
|
||||
Genode::Session_env const &_session_env;
|
||||
Transient_link_state _transient_link_state { DOWN_ACKNOWLEDGED };
|
||||
Signal_context_capability _session_link_state_sigh { };
|
||||
Genode::Session_label const _label;
|
||||
Configuration const *_config_ptr;
|
||||
Genode::Session_env const &_session_env;
|
||||
Transient_link_state _transient_link_state { DOWN_ACKNOWLEDGED };
|
||||
Signal_context_capability _session_link_state_sigh { };
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Interface_policy(Interface_policy const &);
|
||||
Interface_policy &operator = (Interface_policy const &);
|
||||
|
||||
void _session_link_state_transition(Transient_link_state tls);
|
||||
|
||||
@ -115,7 +120,7 @@ class Net::Nic_session_component : private Nic_session_component_base,
|
||||
***************************/
|
||||
|
||||
Domain_name determine_domain_name() const override;
|
||||
void handle_config(Configuration const &config) override { _config = config; }
|
||||
void handle_config(Configuration const &config) override { _config_ptr = &config; }
|
||||
Genode::Session_label const &label() const override { return _label; }
|
||||
bool report_empty() const override { return _session_env.report_empty(); };
|
||||
void report(Genode::Xml_generator &xml) const override { _session_env.report(xml); };
|
||||
@ -172,12 +177,18 @@ class Net::Nic_session_root
|
||||
Cached_timer &_timer;
|
||||
Mac_allocator _mac_alloc;
|
||||
Genode::Constructible<Mac_address> _router_mac { };
|
||||
Reference<Configuration> _config;
|
||||
Configuration *_config_ptr;
|
||||
Quota &_shared_quota;
|
||||
Interface_list &_interfaces;
|
||||
|
||||
void _invalid_downlink(char const *reason);
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Nic_session_root(Nic_session_root const &);
|
||||
Nic_session_root &operator = (Nic_session_root const &);
|
||||
|
||||
|
||||
/********************
|
||||
** Root_component **
|
||||
@ -195,7 +206,7 @@ class Net::Nic_session_root
|
||||
Quota &shared_quota,
|
||||
Interface_list &interfaces);
|
||||
|
||||
void handle_config(Configuration &config) { _config = Reference<Configuration>(config); }
|
||||
void handle_config(Configuration &config) { _config_ptr = &config; }
|
||||
};
|
||||
|
||||
#endif /* _NIC_SESSION_ROOT_H_ */
|
||||
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* \brief Reference that can be overwritten
|
||||
* \author Martin Stein
|
||||
* \date 2016-08-24
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _REFERENCE_H_
|
||||
#define _REFERENCE_H_
|
||||
|
||||
namespace Net {
|
||||
|
||||
template <typename> class Reference;
|
||||
template <typename> class Const_reference;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
class Net::Reference
|
||||
{
|
||||
private:
|
||||
|
||||
T *_obj;
|
||||
|
||||
public:
|
||||
|
||||
Reference(T &obj) : _obj(&obj) { }
|
||||
|
||||
T &operator () () const { return *_obj; }
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
class Net::Const_reference
|
||||
{
|
||||
private:
|
||||
|
||||
T const *_obj;
|
||||
|
||||
public:
|
||||
|
||||
Const_reference(T const &obj) : _obj(&obj) { }
|
||||
|
||||
T const &operator () () const { return *_obj; }
|
||||
};
|
||||
|
||||
#endif /* _REFERENCE_H_ */
|
@ -50,7 +50,7 @@ Interface_policy::Interface_policy(Genode::Session_label const &label,
|
||||
Configuration const &config)
|
||||
:
|
||||
_label { label },
|
||||
_config { config },
|
||||
_config_ptr { &config },
|
||||
_session_env { session_env }
|
||||
{ }
|
||||
|
||||
@ -60,13 +60,13 @@ Net::Uplink_session_component::Interface_policy::determine_domain_name() const
|
||||
{
|
||||
Domain_name domain_name;
|
||||
try {
|
||||
Session_policy policy(_label, _config().node());
|
||||
Session_policy policy(_label, _config_ptr->node());
|
||||
domain_name = policy.attribute_value("domain", Domain_name());
|
||||
if (domain_name == Domain_name() && _config().verbose())
|
||||
if (domain_name == Domain_name() && _config_ptr->verbose())
|
||||
log("[?] no domain attribute in policy for downlink label \"", _label, "\"");
|
||||
}
|
||||
catch (Session_policy::No_policy_defined) {
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[?] no policy for downlink label \"", _label, "\""); }
|
||||
}
|
||||
return domain_name;
|
||||
@ -124,7 +124,7 @@ Net::Uplink_session_root::Uplink_session_root(Env &env,
|
||||
Root_component<Uplink_session_component> { &env.ep().rpc_ep(), &alloc },
|
||||
_env { env },
|
||||
_timer { timer },
|
||||
_config { config },
|
||||
_config_ptr { &config },
|
||||
_shared_quota { shared_quota },
|
||||
_interfaces { interfaces }
|
||||
{ }
|
||||
@ -160,7 +160,7 @@ Net::Uplink_session_root::_create_session(char const *args)
|
||||
session_at, session_env,
|
||||
Arg_string::find_arg(args, "tx_buf_size").ulong_value(0),
|
||||
Arg_string::find_arg(args, "rx_buf_size").ulong_value(0),
|
||||
_timer, mac, label, _interfaces, _config(), ram_ds);
|
||||
_timer, mac, label, _interfaces, *_config_ptr, ram_ds);
|
||||
});
|
||||
}
|
||||
catch (Region_map::Invalid_dataspace) {
|
||||
@ -208,6 +208,6 @@ Net::Uplink_session_root::_destroy_session(Uplink_session_component *session)
|
||||
|
||||
void Net::Uplink_session_root::_invalid_downlink(char const *reason)
|
||||
{
|
||||
if (_config().verbose()) {
|
||||
if (_config_ptr->verbose()) {
|
||||
log("[?] invalid downlink (", reason, ")"); }
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
/* local includes */
|
||||
#include <mac_allocator.h>
|
||||
#include <interface.h>
|
||||
#include <reference.h>
|
||||
#include <report.h>
|
||||
#include <session_env.h>
|
||||
#include <communication_buffer.h>
|
||||
@ -63,9 +62,15 @@ class Net::Uplink_session_component : private Uplink_session_component_base,
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Session_label const _label;
|
||||
Const_reference<Configuration> _config;
|
||||
Genode::Session_env const &_session_env;
|
||||
Genode::Session_label const _label;
|
||||
Configuration const *_config_ptr;
|
||||
Genode::Session_env const &_session_env;
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Interface_policy(Interface_policy const &);
|
||||
Interface_policy &operator = (Interface_policy const &);
|
||||
|
||||
public:
|
||||
|
||||
@ -79,7 +84,7 @@ class Net::Uplink_session_component : private Uplink_session_component_base,
|
||||
***************************/
|
||||
|
||||
Domain_name determine_domain_name() const override;
|
||||
void handle_config(Configuration const &config) override { _config = config; }
|
||||
void handle_config(Configuration const &config) override { _config_ptr = &config; }
|
||||
Genode::Session_label const &label() const override { return _label; }
|
||||
bool report_empty() const override { return _session_env.report_empty(); };
|
||||
void report(Genode::Xml_generator &xml) const override { _session_env.report(xml); };
|
||||
@ -122,14 +127,19 @@ class Net::Uplink_session_root
|
||||
|
||||
enum { MAC_ALLOC_BASE = 0x02 };
|
||||
|
||||
Genode::Env &_env;
|
||||
Cached_timer &_timer;
|
||||
Reference<Configuration> _config;
|
||||
Quota &_shared_quota;
|
||||
Interface_list &_interfaces;
|
||||
Genode::Env &_env;
|
||||
Cached_timer &_timer;
|
||||
Configuration *_config_ptr;
|
||||
Quota &_shared_quota;
|
||||
Interface_list &_interfaces;
|
||||
|
||||
void _invalid_downlink(char const *reason);
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Uplink_session_root(Uplink_session_root const &);
|
||||
Uplink_session_root &operator = (Uplink_session_root const &);
|
||||
|
||||
/********************
|
||||
** Root_component **
|
||||
@ -147,7 +157,7 @@ class Net::Uplink_session_root
|
||||
Quota &shared_quota,
|
||||
Interface_list &interfaces);
|
||||
|
||||
void handle_config(Configuration &config) { _config = Reference<Configuration>(config); }
|
||||
void handle_config(Configuration &config) { _config_ptr = &config; }
|
||||
};
|
||||
|
||||
#endif /* _UPLINK_SESSION_ROOT_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user