mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
Kernel: Use a public member for NetworkAdapter on_receive
This commit is contained in:
parent
6d1418aa7a
commit
498f8c01a2
3 changed files with 5 additions and 6 deletions
|
@ -88,8 +88,8 @@ void NetworkAdapter::did_receive(const u8* data, int length)
|
|||
m_packets_in++;
|
||||
m_bytes_in += length;
|
||||
m_packet_queue.append(KBuffer::copy(data, length));
|
||||
if (m_on_receive)
|
||||
m_on_receive();
|
||||
if (on_receive)
|
||||
on_receive();
|
||||
}
|
||||
|
||||
Optional<KBuffer> NetworkAdapter::dequeue_packet()
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
u32 packets_out() const { return m_packets_out; }
|
||||
u32 bytes_out() const { return m_bytes_out; }
|
||||
|
||||
void set_on_receive(Function<void()> on_receive) { m_on_receive = move(on_receive); }
|
||||
Function<void()> on_receive;
|
||||
|
||||
protected:
|
||||
NetworkAdapter();
|
||||
|
@ -65,5 +65,4 @@ private:
|
|||
u32 m_bytes_in { 0 };
|
||||
u32 m_packets_out { 0 };
|
||||
u32 m_bytes_out { 0 };
|
||||
Function<void()> m_on_receive;
|
||||
};
|
||||
|
|
|
@ -50,9 +50,9 @@ void NetworkTask_main()
|
|||
adapter.ipv4_netmask().to_string().characters(),
|
||||
adapter.ipv4_gateway().to_string().characters());
|
||||
|
||||
adapter.set_on_receive([&pending_packets]() {
|
||||
adapter.on_receive = [&pending_packets]() {
|
||||
pending_packets++;
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
auto dequeue_packet = [&pending_packets]() -> Optional<KBuffer> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue