nic bridge: connect to backend NIC on startup

After announcing the NIC service, the bridge connects to the driver to
ensure to see any incoming traffic in case the client itself only reacts
on connects from LAN (e.g., the netperf server).

Also, some styling issues were fixed.
This commit is contained in:
Christian Helmuth 2013-09-18 16:21:45 +02:00 committed by Norman Feske
parent f1dcaa746d
commit 3056c718c8
3 changed files with 12 additions and 5 deletions

View File

@ -139,9 +139,9 @@ Session_component::Session_component(Genode::Allocator *allocator,
set_ipv4_address(ip);
if (verbose)
PDBG("\nmac=%02x.%02x.%02x.%02x.%02x.%02x ip=%d.%d.%d.%d",
PLOG("vmac=%02x:%02x:%02x:%02x:%02x:%02x ip=%d.%d.%d.%d",
vmac.addr[0], vmac.addr[1], vmac.addr[2],
vmac.addr[3], vmac.addr[4], vmac.addr[5],
vmac.addr[3], vmac.addr[4], vmac.addr[5],
ip.addr[0], ip.addr[1], ip.addr[2], ip.addr[3]);
}
}

View File

@ -183,11 +183,11 @@ namespace Net {
Session_policy policy(label);
policy.attribute("ip_addr").value(ip_addr, sizeof(ip_addr));
if (verbose) PDBG("policy: %s ip_addr = %s", label.string(), ip_addr);
if (verbose) PLOG("policy: %s ip_addr = %s", label.string(), ip_addr);
} catch (Xml_node::Nonexistent_attribute) {
if (verbose) PDBG("Missing \"ip_addr\" attribute in policy definition");
if (verbose) PLOG("Missing \"ip_addr\" attribute in policy definition");
} catch (Session_policy::No_policy_defined) {
if (verbose) PDBG("Invalid session request, no matching policy");;
if (verbose) PLOG("Invalid session request, no matching policy");;
}
size_t ram_quota =

View File

@ -21,6 +21,7 @@
/* local includes */
#include "component.h"
#include "nic.h"
#include "env.h"
@ -45,6 +46,12 @@ int main(int, char **)
/* announce NIC service */
env()->parent()->announce(ep.manage(&nic_root));
/* connect to NIC backend to actually see incoming traffic */
Net::Ethernet_frame::Mac_address mac(Net::Env::nic()->mac());
printf("--- NIC bridge started (mac=%02x:%02x:%02x:%02x:%02x:%02x) ---\n",
mac.addr[0], mac.addr[1], mac.addr[2],
mac.addr[3], mac.addr[4], mac.addr[5]);
while (true) {
Signal s = Net::Env::receiver()->wait_for_signal();
static_cast<Signal_dispatcher_base *>(s.context())->dispatch(s.num());