diff --git a/repos/pc/src/lib/wifi/socket_call.cc b/repos/pc/src/lib/wifi/socket_call.cc index ae7023af59..8cc5746b60 100644 --- a/repos/pc/src/lib/wifi/socket_call.cc +++ b/repos/pc/src/lib/wifi/socket_call.cc @@ -15,6 +15,7 @@ #include #include #include +#include /* DDE Linux includes */ #include @@ -470,13 +471,20 @@ class Lx::Socket static Lx::Socket *_socket; +/* implemented in wlan.cc */ extern Genode::Blockade *wpa_blockade; +/* implemented in wlan.cc */ +void _wifi_report_mac_address(Net::Mac_address const &mac_address); + + extern "C" int socketcall_task_function(void *) { static Lx::Socket inst(Lx_kit::env().env.ep()); _socket = &inst; + _wifi_report_mac_address({ (void *) lx_get_mac_addr() }); + wpa_blockade->wakeup(); while (true) { diff --git a/repos/pc/src/lib/wifi/wlan.cc b/repos/pc/src/lib/wifi/wlan.cc index bac9c19ae7..ea00dde856 100644 --- a/repos/pc/src/lib/wifi/wlan.cc +++ b/repos/pc/src/lib/wifi/wlan.cc @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include /* DDE Linux includes */ @@ -89,6 +91,64 @@ extern "C" char const *wifi_ifname(void) return "wlan0"; } + +struct Mac_address_reporter +{ + bool _enabled = false; + + Net::Mac_address _mac_address { }; + + Constructible _reporter { }; + + Env &_env; + + Signal_context_capability _sigh; + + Mac_address_reporter(Env &env, Signal_context_capability sigh) + : _env(env), _sigh(sigh) + { + Attached_rom_dataspace config { _env, "config" }; + + config.xml().with_optional_sub_node("report", [&] (Xml_node const &xml) { + _enabled = xml.attribute_value("mac_address", false); }); + } + + void mac_address(Net::Mac_address const &mac_address) + { + _mac_address = mac_address; + + Signal_transmitter(_sigh).submit(); + } + + void report() + { + if (!_enabled) + return; + + _reporter.construct(_env, "devices"); + _reporter->enabled(true); + + Reporter::Xml_generator report(*_reporter, [&] () { + report.node("nic", [&] () { + report.attribute("mac_address", String<32>(_mac_address)); + }); + }); + + /* report only once */ + _enabled = false; + } +}; + +Constructible mac_address_reporter; + + +/* used from socket_call.cc */ +void _wifi_report_mac_address(Net::Mac_address const &mac_address) +{ + mac_address_reporter->mac_address(mac_address); +} + + struct Wlan { Env &_env; @@ -103,10 +163,14 @@ struct Wlan } genode_uplink_notify_peers(); + + mac_address_reporter->report(); } Wlan(Env &env) : _env { env } { + mac_address_reporter.construct(_env, _signal_handler); + genode_uplink_init(genode_env_ptr(_env), genode_allocator_ptr(Lx_kit::env().heap), genode_signal_handler_ptr(_signal_handler));