mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
parent
208547e3af
commit
52fb4eee5f
@ -15,6 +15,7 @@
|
||||
#include <base/allocator.h>
|
||||
#include <base/env.h>
|
||||
#include <base/log.h>
|
||||
#include <net/mac_address.h>
|
||||
|
||||
/* DDE Linux includes */
|
||||
#include <wifi/socket_call.h>
|
||||
@ -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) {
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <base/component.h>
|
||||
#include <base/env.h>
|
||||
#include <os/reporter.h>
|
||||
#include <net/mac_address.h>
|
||||
#include <genode_c_api/uplink.h>
|
||||
|
||||
/* 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> _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> 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));
|
||||
|
Loading…
Reference in New Issue
Block a user