mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
Kernel: Move packet allocation into helper methods
This commit is contained in:
parent
c739b3cafa
commit
f8310b7796
2 changed files with 48 additions and 30 deletions
|
@ -26,6 +26,18 @@ class NetworkAdapter;
|
|||
|
||||
using NetworkByteBuffer = AK::Detail::ByteBuffer<1500>;
|
||||
|
||||
struct PacketWithTimestamp : public RefCounted<PacketWithTimestamp> {
|
||||
PacketWithTimestamp(KBuffer buffer, Time timestamp)
|
||||
: buffer(move(buffer))
|
||||
, timestamp(timestamp)
|
||||
{
|
||||
}
|
||||
|
||||
KBuffer buffer;
|
||||
Time timestamp;
|
||||
IntrusiveListNode<PacketWithTimestamp, RefPtr<PacketWithTimestamp>> packet_node;
|
||||
};
|
||||
|
||||
class NetworkAdapter : public RefCounted<NetworkAdapter> {
|
||||
public:
|
||||
template<typename Callback>
|
||||
|
@ -70,6 +82,9 @@ public:
|
|||
u32 packets_out() const { return m_packets_out; }
|
||||
u32 bytes_out() const { return m_bytes_out; }
|
||||
|
||||
RefPtr<PacketWithTimestamp> acquire_packet_buffer(size_t);
|
||||
void release_packet_buffer(PacketWithTimestamp&);
|
||||
|
||||
Function<void()> on_receive;
|
||||
|
||||
protected:
|
||||
|
@ -89,18 +104,6 @@ private:
|
|||
IPv4Address m_ipv4_netmask;
|
||||
IPv4Address m_ipv4_gateway;
|
||||
|
||||
struct PacketWithTimestamp : public RefCounted<PacketWithTimestamp> {
|
||||
PacketWithTimestamp(KBuffer buffer, Time timestamp)
|
||||
: buffer(move(buffer))
|
||||
, timestamp(timestamp)
|
||||
{
|
||||
}
|
||||
|
||||
KBuffer buffer;
|
||||
Time timestamp;
|
||||
IntrusiveListNode<PacketWithTimestamp, RefPtr<PacketWithTimestamp>> packet_node;
|
||||
};
|
||||
|
||||
// FIXME: Make this configurable
|
||||
static constexpr size_t max_packet_buffers = 1024;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue