mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-22 13:02:56 +01:00
black_hole: add support for Uplink client
The uplink client simply drops and acknowledges packets it receives. issue #5104
This commit is contained in:
committed by
Christian Helmuth
parent
61115c3776
commit
240819b708
@@ -2,7 +2,7 @@ The 'black_hole' component provides dummy implementations of common
|
||||
session interfaces.
|
||||
|
||||
At this time, the following sessions are provided if enabled
|
||||
in the configuration of the component:
|
||||
in the configuration of the component.
|
||||
|
||||
* Audio_in
|
||||
* Audio_out
|
||||
@@ -25,3 +25,11 @@ in the configuration of the component:
|
||||
<gpu/>
|
||||
<usb/>
|
||||
</config>
|
||||
|
||||
Black hole optionally requests the following sessions as client.
|
||||
|
||||
* Uplink client
|
||||
|
||||
<config>
|
||||
<uplink_client/>
|
||||
</config>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<xs:element name="gpu"/>
|
||||
<xs:element name="rom"/>
|
||||
<xs:element name="uplink"/>
|
||||
<xs:element name="uplink_client"/>
|
||||
<xs:element name="nic"/>
|
||||
<xs:element name="event"/>
|
||||
<xs:element name="capture"/>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "event.h"
|
||||
#include "nic.h"
|
||||
#include "uplink.h"
|
||||
#include "uplink_client.h"
|
||||
#include "report.h"
|
||||
#include "rom.h"
|
||||
#include "gpu.h"
|
||||
@@ -55,6 +56,7 @@ struct Black_hole::Main
|
||||
Genode::Constructible<Rom_root> rom_root { };
|
||||
Genode::Constructible<Gpu_root> gpu_root { };
|
||||
Genode::Constructible<Usb_root> usb_root { };
|
||||
Genode::Constructible<Uplink_client> uplink_client { };
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
@@ -100,6 +102,10 @@ struct Black_hole::Main
|
||||
usb_root.construct(env, heap);
|
||||
env.parent().announce(env.ep().manage(*usb_root));
|
||||
}
|
||||
|
||||
if (_config_rom.xml().has_sub_node("uplink_client")) {
|
||||
uplink_client.construct(env, heap);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
73
repos/os/src/server/black_hole/uplink_client.h
Normal file
73
repos/os/src/server/black_hole/uplink_client.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* \brief Uplink client that drops and acks received packets
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2023-12-14
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023 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 _UPLINK_CLIENT_H_
|
||||
#define _UPLINK_CLIENT_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <net/mac_address.h>
|
||||
#include <nic/packet_allocator.h>
|
||||
#include <uplink_session/connection.h>
|
||||
|
||||
namespace Genode {
|
||||
class Uplink_client;
|
||||
}
|
||||
|
||||
class Genode::Uplink_client : Noncopyable
|
||||
{
|
||||
private:
|
||||
|
||||
Env &_env;
|
||||
Allocator &_alloc;
|
||||
|
||||
Nic::Packet_allocator _pkt_alloc { &_alloc };
|
||||
|
||||
static Net::Mac_address _default_mac_address()
|
||||
{
|
||||
Net::Mac_address mac_addr { (uint8_t)0 };
|
||||
|
||||
mac_addr.addr[0] = 0x02; /* unicast, locally managed MAC address */
|
||||
mac_addr.addr[5] = 0x01; /* arbitrary index */
|
||||
|
||||
return mac_addr;
|
||||
}
|
||||
|
||||
Net::Mac_address _mac_addr { _default_mac_address() };
|
||||
Uplink::Connection _uplink { _env, &_pkt_alloc, 64*1024, 64*1024, _mac_addr };
|
||||
|
||||
Signal_handler<Uplink_client> _packet_stream_handler { _env.ep(), *this,
|
||||
&Uplink_client::_handle_packet_stream };
|
||||
|
||||
void _handle_packet_stream()
|
||||
{
|
||||
while (_uplink.rx()->packet_avail() &&
|
||||
_uplink.rx()->ready_to_ack()) {
|
||||
Packet_descriptor const pkt { _uplink.rx()->get_packet() };
|
||||
if (!pkt.size() || !_uplink.rx()->packet_valid(pkt)) {
|
||||
continue;
|
||||
}
|
||||
_uplink.rx()->acknowledge_packet(pkt);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Uplink_client(Env &env, Allocator &alloc)
|
||||
: _env(env), _alloc(alloc)
|
||||
{
|
||||
_uplink.rx_channel()->sigh_ready_to_ack(_packet_stream_handler);
|
||||
_uplink.rx_channel()->sigh_packet_avail(_packet_stream_handler);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _UPLINK_CLIENT_H_ */
|
||||
Reference in New Issue
Block a user