diff --git a/repos/os/src/server/nic_router/interface.cc b/repos/os/src/server/nic_router/interface.cc index c776465b7a..3e9985a2c5 100644 --- a/repos/os/src/server/nic_router/interface.cc +++ b/repos/os/src/server/nic_router/interface.cc @@ -198,37 +198,13 @@ Interface::_new_link(L3_protocol const protocol, { switch (protocol) { case L3_protocol::TCP: - { - Tcp_link &link = *new (_alloc) - Tcp_link(*this, local, remote_port_alloc, remote_domain, - remote, _timer, _config(), protocol); - - _tcp_links.insert(&link); - _domain.tcp_links().insert(&link.client()); - remote_domain.tcp_links().insert(&link.server()); - if (_config().verbose()) { - log("New TCP client link: ", link.client(), " at ", _domain); - log("New TCP server link: ", link.server(), - " at ", remote_domain); - } - return; - } + new (_alloc) Tcp_link(*this, local, remote_port_alloc, remote_domain, + remote, _timer, _config(), protocol); + break; case L3_protocol::UDP: - { - Udp_link &link = *new (_alloc) - Udp_link(*this, local, remote_port_alloc, remote_domain, - remote, _timer, _config(), protocol); - - _udp_links.insert(&link); - _domain.udp_links().insert(&link.client()); - remote_domain.udp_links().insert(&link.server()); - if (_config().verbose()) { - log("New UDP client link: ", link.client(), " at ", _domain); - log("New UDP server link: ", link.server(), - " at ", remote_domain); - } - return; - } + new (_alloc) Udp_link(*this, local, remote_port_alloc, remote_domain, + remote, _timer, _config(), protocol); + break; default: throw Bad_transport_protocol(); } } diff --git a/repos/os/src/server/nic_router/link.cc b/repos/os/src/server/nic_router/link.cc index 8ccab296da..e31b43b284 100644 --- a/repos/os/src/server/nic_router/link.cc +++ b/repos/os/src/server/nic_router/link.cc @@ -54,7 +54,12 @@ Link_side::Link_side(Domain &domain, Link &link) : _domain(domain), _id(id), _link(link) -{ } +{ + if (link.config().verbose()) { + log("[", domain, "] New ", l3_protocol_name(link.protocol()), + " link ", is_client() ? "client" : "server", ": ", *this); + } +} Link_side const &Link_side::find_by_id(Link_side_id const &id) const @@ -119,14 +124,17 @@ Link::Link(Interface &cln_interface, Microseconds const close_timeout) : _config(config), - _client(cln_interface.domain(), cln_id, *this), _client_interface(cln_interface), _server_port_alloc(srv_port_alloc), - _server(srv_domain, srv_id, *this), _close_timeout(timer, *this, &Link::_handle_close_timeout), _close_timeout_us(close_timeout), - _protocol(protocol) + _protocol(protocol), + _client(cln_interface.domain(), cln_id, *this), + _server(srv_domain, srv_id, *this) { + _client_interface.links(_protocol).insert(this); + _client.domain().links(_protocol).insert(&_client); + _server.domain().links(_protocol).insert(&_server); _close_timeout.schedule(_close_timeout_us); } diff --git a/repos/os/src/server/nic_router/link.h b/repos/os/src/server/nic_router/link.h index e94b78b60e..f33819b5b6 100644 --- a/repos/os/src/server/nic_router/link.h +++ b/repos/os/src/server/nic_router/link.h @@ -126,13 +126,13 @@ class Net::Link : public Link_list::Element protected: Configuration &_config; - Link_side _client; Interface &_client_interface; Pointer const _server_port_alloc; - Link_side _server; Timer::One_shot_timeout _close_timeout; Genode::Microseconds const _close_timeout_us; L3_protocol const _protocol; + Link_side _client; + Link_side _server; void _handle_close_timeout(Genode::Duration); @@ -166,9 +166,10 @@ class Net::Link : public Link_list::Element ** Accessors ** ***************/ - Link_side &client() { return _client; } - Link_side &server() { return _server; } - Configuration &config() { return _config; } + Link_side &client() { return _client; } + Link_side &server() { return _server; } + Configuration &config() { return _config; } + L3_protocol protocol() const { return _protocol; } };